/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
+ * Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-2000,
* Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
- * Copyright (C) Jean François Micouleau 1998-2000.
+ * Copyright (C) Jean François Micouleau 1998-2000,
+ * Copyright (C) Gerald Carter 2000-2002
+ * Copyright (C) Tim Potter 2001.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include "includes.h"
-extern int DEBUGLEVEL;
/*******************************************************************
return the length of a UNISTR string.
********************************************************************/
+
static uint32 str_len_uni(UNISTR *source)
{
uint32 i=0;
- if (!source->buffer) return 0;
+ if (!source->buffer)
+ return 0;
+
+ while (source->buffer[i])
+ i++;
- while (source->buffer[i]!=0x0000)
- {
- i++;
- }
return i;
}
/*******************************************************************
This should be moved in a more generic lib.
********************************************************************/
+
static BOOL spoolss_io_system_time(char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime)
{
- if(!prs_uint16("year", ps, depth, &(systime->year)))
+ if(!prs_uint16("year", ps, depth, &systime->year))
return False;
- if(!prs_uint16("month", ps, depth, &(systime->month)))
+ if(!prs_uint16("month", ps, depth, &systime->month))
return False;
- if(!prs_uint16("dayofweek", ps, depth, &(systime->dayofweek)))
+ if(!prs_uint16("dayofweek", ps, depth, &systime->dayofweek))
return False;
- if(!prs_uint16("day", ps, depth, &(systime->day)))
+ if(!prs_uint16("day", ps, depth, &systime->day))
return False;
- if(!prs_uint16("hour", ps, depth, &(systime->hour)))
+ if(!prs_uint16("hour", ps, depth, &systime->hour))
return False;
- if(!prs_uint16("minute", ps, depth, &(systime->minute)))
+ if(!prs_uint16("minute", ps, depth, &systime->minute))
return False;
- if(!prs_uint16("second", ps, depth, &(systime->second)))
+ if(!prs_uint16("second", ps, depth, &systime->second))
return False;
- if(!prs_uint16("milliseconds", ps, depth, &(systime->milliseconds)))
+ if(!prs_uint16("milliseconds", ps, depth, &systime->milliseconds))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
{
systime->year=unixtime->tm_year+1900;
/*******************************************************************
reads or writes an DOC_INFO structure.
********************************************************************/
+
static BOOL smb_io_doc_info_1(char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth)
{
if (info_1 == NULL) return False;
if(!prs_align(ps))
return False;
- if(!prs_uint32("p_docname", ps, depth, &(info_1->p_docname)))
+ if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname))
return False;
- if(!prs_uint32("p_outputfile", ps, depth, &(info_1->p_outputfile)))
+ if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile))
return False;
- if(!prs_uint32("p_datatype", ps, depth, &(info_1->p_datatype)))
+ if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype))
return False;
- if(!smb_io_unistr2("", &(info_1->docname), info_1->p_docname, ps, depth))
+ if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth))
return False;
- if(!smb_io_unistr2("", &(info_1->outputfile), info_1->p_outputfile, ps, depth))
+ if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth))
return False;
- if(!smb_io_unistr2("", &(info_1->datatype), info_1->p_datatype, ps, depth))
+ if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth))
return False;
return True;
/*******************************************************************
reads or writes an DOC_INFO structure.
********************************************************************/
+
static BOOL smb_io_doc_info(char *desc, DOC_INFO *info, prs_struct *ps, int depth)
{
uint32 useless_ptr=0;
if(!prs_align(ps))
return False;
- if(!prs_uint32("switch_value", ps, depth, &(info->switch_value)))
+ if(!prs_uint32("switch_value", ps, depth, &info->switch_value))
return False;
- if(!prs_uint32("doc_info_X ptr", ps, depth, &(useless_ptr)))
+ if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr))
return False;
switch (info->switch_value)
{
case 1:
- if(!smb_io_doc_info_1("",&(info->doc_info_1), ps, depth))
+ if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth))
return False;
break;
case 2:
Maybe one day with Windows for dishwasher 2037 ...
*/
- /* smb_io_doc_info_2("",&(info->doc_info_2), ps, depth); */
+ /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
break;
default:
DEBUG(0,("Something is obviously wrong somewhere !\n"));
/*******************************************************************
reads or writes an DOC_INFO_CONTAINER structure.
********************************************************************/
+
static BOOL smb_io_doc_info_container(char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth)
{
if (cont == NULL) return False;
if(!prs_align(ps))
return False;
- if(!prs_uint32("level", ps, depth, &(cont->level)))
+ if(!prs_uint32("level", ps, depth, &cont->level))
return False;
- if(!smb_io_doc_info("",&(cont->docinfo), ps, depth))
+ if(!smb_io_doc_info("",&cont->docinfo, ps, depth))
return False;
return True;
/*******************************************************************
reads or writes an NOTIFY OPTION TYPE structure.
********************************************************************/
+
+/* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
+ structure. The _TYPE structure is really the deferred referrants (i.e
+ the notify fields array) of the _TYPE structure. -tpot */
+
static BOOL smb_io_notify_option_type(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "smb_io_notify_option_type");
/*******************************************************************
reads or writes an NOTIFY OPTION TYPE DATA.
********************************************************************/
+
static BOOL smb_io_notify_option_type_data(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
{
int i;
/* parse the option type data */
for(i=0;i<type->count2;i++)
- if(!prs_uint16("fields",ps,depth,&(type->fields[i])))
+ if(!prs_uint16("fields",ps,depth,&type->fields[i]))
return False;
return True;
}
/*******************************************************************
reads or writes an NOTIFY OPTION structure.
********************************************************************/
+
static BOOL smb_io_notify_option_type_ctr(char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth)
{
int i;
/* reading */
if (UNMARSHALLING(ps))
- if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)malloc(ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL)
+ if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)prs_alloc_mem(ps,ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL)
return False;
/* the option type struct */
/*******************************************************************
reads or writes an NOTIFY OPTION structure.
********************************************************************/
+
static BOOL smb_io_notify_option(char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "smb_io_notify_option");
/*******************************************************************
reads or writes an NOTIFY INFO DATA structure.
********************************************************************/
+
static BOOL smb_io_notify_info_data(char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth)
{
uint32 useless_ptr=0xADDE0FF0;
/*******************************************************************
reads or writes an NOTIFY INFO DATA structure.
********************************************************************/
+
BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
prs_struct *ps, int depth)
{
x=data->notify_data.data.length+1;
if(!prs_uint32("string length", ps, depth, &x ))
return False;
- if(!prs_uint16s(True,"string",ps,depth,data->notify_data.data.string,x))
- return False;
+ if (MARSHALLING(ps)) {
+ /* These are already in little endian format. Don't byte swap. */
+ if (x == 1) {
+
+ /* No memory allocated for this string
+ therefore following the data.string
+ pointer is a bad idea. Use a pointer to
+ the uint32 length union member to
+ provide a source for a unicode NULL */
+
+ if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
+ return False;
+ } else {
+ if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
+ return False;
+ }
+ } else {
+
+ /* Tallocate memory for string */
+
+ data->notify_data.data.string = (uint16 *)prs_alloc_mem(ps, x * 2);
+ if (!data->notify_data.data.string)
+ return False;
+
+ if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
+ return False;
+ }
}
+#if 0 /* JERRY */
+
+ /* Win2k does not seem to put this parse align here */
+
if(!prs_align(ps))
return False;
+#endif
return True;
}
/*******************************************************************
reads or writes an NOTIFY INFO structure.
********************************************************************/
+
static BOOL smb_io_notify_info(char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth)
{
int i;
return True;
}
-
/*******************************************************************
********************************************************************/
+
static BOOL spool_io_user_level_1(char *desc, SPOOL_USER_1 *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "");
depth++;
/* reading */
- if (ps->io)
+ if (UNMARSHALLING(ps))
ZERO_STRUCTP(q_u);
if (!prs_align(ps))
return False;
- if (!prs_uint32("size", ps, depth, &(q_u->size)))
+ if (!prs_uint32("size", ps, depth, &q_u->size))
return False;
- if (!prs_uint32("client_name_ptr", ps, depth, &(q_u->client_name_ptr)))
+ if (!prs_uint32("client_name_ptr", ps, depth, &q_u->client_name_ptr))
return False;
- if (!prs_uint32("user_name_ptr", ps, depth, &(q_u->user_name_ptr)))
+ if (!prs_uint32("user_name_ptr", ps, depth, &q_u->user_name_ptr))
return False;
- if (!prs_uint32("build", ps, depth, &(q_u->build)))
+ if (!prs_uint32("build", ps, depth, &q_u->build))
return False;
- if (!prs_uint32("major", ps, depth, &(q_u->major)))
+ if (!prs_uint32("major", ps, depth, &q_u->major))
return False;
- if (!prs_uint32("minor", ps, depth, &(q_u->minor)))
+ if (!prs_uint32("minor", ps, depth, &q_u->minor))
return False;
- if (!prs_uint32("processor", ps, depth, &(q_u->processor)))
+ if (!prs_uint32("processor", ps, depth, &q_u->processor))
return False;
- if (!smb_io_unistr2("", &(q_u->client_name), q_u->client_name_ptr, ps, depth))
+ if (!smb_io_unistr2("", &q_u->client_name, q_u->client_name_ptr, ps, depth))
return False;
if (!prs_align(ps))
return False;
- if (!smb_io_unistr2("", &(q_u->user_name), q_u->user_name_ptr, ps, depth))
+ if (!smb_io_unistr2("", &q_u->user_name, q_u->user_name_ptr, ps, depth))
return False;
return True;
/*******************************************************************
********************************************************************/
+
static BOOL spool_io_user_level(char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
{
if (q_u==NULL)
switch (q_u->level) {
case 1:
- if (!spool_io_user_level_1("", &(q_u->user1), ps, depth))
+ if (!spool_io_user_level_1("", &q_u->user1, ps, depth))
return False;
break;
default:
* read or write a DEVICEMODE struct.
* on reading allocate memory for the private member
********************************************************************/
-static BOOL spoolss_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
+
+BOOL spoolss_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
{
prs_debug(ps, depth, desc, "spoolss_io_devmode");
depth++;
- if (!prs_uint16s(True,"devicename", ps, depth, devmode->devicename.buffer, 32))
+ if (UNMARSHALLING(ps)) {
+ devmode->devicename.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
+ if (devmode->devicename.buffer == NULL)
+ return False;
+ }
+
+ if (!prs_uint16uni(True,"devicename", ps, depth, devmode->devicename.buffer, 32))
return False;
if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
return False;
return False;
if (!prs_uint16("collate", ps, depth, &devmode->collate))
return False;
- if (!prs_uint16s(True, "formname", ps, depth, devmode->formname.buffer, 32))
+
+ if (UNMARSHALLING(ps)) {
+ devmode->formname.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
+ if (devmode->formname.buffer == NULL)
+ return False;
+ }
+
+ if (!prs_uint16uni(True, "formname", ps, depth, devmode->formname.buffer, 32))
return False;
if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
return False;
return False;
if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency))
return False;
+
+ /*
+ * Conditional parsing. Assume that the DeviceMode has been
+ * zero'd by the caller.
+ */
+ switch(devmode->specversion) {
+
+ /* Used by spooler when issuing OpenPrinter() calls. NT 3.5x? */
+ case 0x0320:
+ break;
+
+ /* See the comments on the DEVMODE in the msdn GDI documentation */
+ /* (WINVER >= 0x0400) */
+ case 0x0400:
+ case 0x0401:
if (!prs_uint32("icmmethod", ps, depth, &devmode->icmmethod))
return False;
if (!prs_uint32("icmintent", ps, depth, &devmode->icmintent))
return False;
if (!prs_uint32("reserved2", ps, depth, &devmode->reserved2))
return False;
+
+ /* (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400) */
+ if (devmode->specversion == 0x401) {
if (!prs_uint32("panningwidth", ps, depth, &devmode->panningwidth))
return False;
if (!prs_uint32("panningheight", ps, depth, &devmode->panningheight))
return False;
+ }
+ break;
+
+ /* log an error if we see something else */
+ default:
+ DEBUG(0,("spoolss_io_devmode: Unknown specversion [0x%x]!\n", devmode->specversion));
+ DEBUG(0,("spoolss_io_devmode: Please report to samba-technical@samba.org\n"));
+ break;
+ }
if (devmode->driverextra!=0) {
if (UNMARSHALLING(ps)) {
- devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8));
+ devmode->private=(uint8 *)prs_alloc_mem(ps, devmode->driverextra*sizeof(uint8));
if(devmode->private == NULL)
return False;
DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode->driverextra));
}
DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra));
- if (!prs_uint8s(True, "private", ps, depth, devmode->private, devmode->driverextra))
+ if (!prs_uint8s(False, "private", ps, depth,
+ devmode->private, devmode->driverextra))
return False;
}
return True;
}
-void free_spoolss_devmode(DEVICEMODE *devmode)
-{
- if (devmode == NULL)
- return;
-
- safe_free(devmode->private);
- safe_free(devmode);
-}
-
/*******************************************************************
Read or write a DEVICEMODE container
********************************************************************/
+
static BOOL spoolss_io_devmode_cont(char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
{
if (dm_c==NULL)
/* so we have a DEVICEMODE to follow */
if (UNMARSHALLING(ps)) {
DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
- dm_c->devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE));
+ dm_c->devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE));
if(dm_c->devmode == NULL)
return False;
- ZERO_STRUCTP(dm_c->devmode);
}
/* this is bad code, shouldn't be there */
/*******************************************************************
********************************************************************/
+
static BOOL spoolss_io_printer_default(char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
{
if (pd==NULL)
if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
return False;
- if (!smb_io_unistr2("datatype", &(pd->datatype), pd->datatype_ptr, ps,depth))
+ if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
return False;
if (!prs_align(ps))
return False;
- if (!spoolss_io_devmode_cont("", &(pd->devmode_cont), ps, depth))
+ if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
return False;
if (!prs_uint32("access_required", ps, depth, &pd->access_required))
/*******************************************************************
* init a structure.
********************************************************************/
+
BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
const fstring printername,
const fstring datatype,
{
DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
q_u->printername_ptr = (printername!=NULL)?1:0;
- init_unistr2(&(q_u->printername), printername, strlen(printername));
+ init_unistr2(&q_u->printername, printername, strlen(printername)+1);
q_u->printer_default.datatype_ptr = 0;
/*
q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
- init_unistr2(&(q_u->printer_default.datatype), datatype, strlen(datatype));
+ init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
*/
q_u->printer_default.devmode_cont.size=0;
q_u->printer_default.devmode_cont.devmode_ptr=0;
q_u->user_switch=1;
q_u->user_ctr.level=1;
q_u->user_ctr.ptr=1;
- q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+8;
+ q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10;
+ q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
+ q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
+ q_u->user_ctr.user1.build=1381;
+ q_u->user_ctr.user1.major=2;
+ q_u->user_ctr.user1.minor=0;
+ q_u->user_ctr.user1.processor=0;
+ init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
+ init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
+
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_addprinterex(
+ TALLOC_CTX *mem_ctx,
+ SPOOL_Q_ADDPRINTEREX *q_u,
+ const char *srv_name,
+ const char* clientname,
+ const char* user_name,
+ uint32 level,
+ PRINTER_INFO_CTR *ctr)
+{
+ DEBUG(5,("make_spoolss_q_addprinterex\n"));
+
+ if (!ctr) return False;
+
+ ZERO_STRUCTP(q_u);
+
+ q_u->server_name_ptr = (srv_name!=NULL)?1:0;
+ init_unistr2(&q_u->server_name, srv_name, strlen(srv_name));
+
+ q_u->level = level;
+
+ q_u->info.level = level;
+ q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
+ switch (level) {
+ case 2:
+ /* init q_u->info.info2 from *info */
+ if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
+ DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
+ return False;
+ }
+ break;
+ default :
+ break;
+ }
+
+ q_u->user_switch=1;
+
+ q_u->user_ctr.level=1;
+ q_u->user_ctr.ptr=1;
q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
q_u->user_ctr.user1.build=1381;
q_u->user_ctr.user1.major=2;
q_u->user_ctr.user1.minor=0;
q_u->user_ctr.user1.processor=0;
- init_unistr2(&(q_u->user_ctr.user1.client_name), clientname, strlen(clientname));
- init_unistr2(&(q_u->user_ctr.user1.user_name), user_name, strlen(user_name));
+ init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
+ init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
+ q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len +
+ q_u->user_ctr.user1.client_name.uni_str_len + 2;
+
+ return True;
+}
+
+/*******************************************************************
+create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
+*******************************************************************/
+
+BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
+ PRINTER_INFO_2 *info)
+{
+
+ SPOOL_PRINTER_INFO_LEVEL_2 *inf;
+
+ /* allocate the necessary memory */
+ if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_2*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_2)))) {
+ DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
+ return False;
+ }
+ inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
+ inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
+ inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
+ inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
+ inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
+ inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
+ inf->location_ptr = (info->location.buffer!=NULL)?1:0;
+ inf->devmode_ptr = (info->devmode!=NULL)?1:0;
+ inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
+ inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
+ inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
+ inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
+ inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
+ inf->attributes = info->attributes;
+ inf->priority = info->priority;
+ inf->default_priority = info->defaultpriority;
+ inf->starttime = info->starttime;
+ inf->untiltime = info->untiltime;
+ inf->cjobs = info->cjobs;
+ inf->averageppm = info->averageppm;
+ init_unistr2_from_unistr(&inf->servername, &info->servername);
+ init_unistr2_from_unistr(&inf->printername, &info->printername);
+ init_unistr2_from_unistr(&inf->sharename, &info->sharename);
+ init_unistr2_from_unistr(&inf->portname, &info->portname);
+ init_unistr2_from_unistr(&inf->drivername, &info->drivername);
+ init_unistr2_from_unistr(&inf->comment, &info->comment);
+ init_unistr2_from_unistr(&inf->location, &info->location);
+ init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
+ init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
+ init_unistr2_from_unistr(&inf->datatype, &info->datatype);
+ init_unistr2_from_unistr(&inf->parameters, &info->parameters);
+ init_unistr2_from_unistr(&inf->datatype, &info->datatype);
+
+ *spool_info2 = inf;
+
return True;
}
* read a structure.
* called from spoolss_q_open_printer_ex (srv_spoolss.c)
********************************************************************/
-BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
+ prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
depth++;
if (!prs_align(ps))
if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
return False;
- if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
+ * called from spoolss_open_printer_ex (cli_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
return False;
- if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
+
+ if (!prs_werror("status code", ps, depth, &(r_u->status)))
return False;
return True;
}
-void free_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u)
+
+/*******************************************************************
+ * read a structure.
+ * called from spoolss_q_open_printer_ex (srv_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
{
- free_spoolss_devmode(q_u->printer_default.devmode_cont.devmode);
+ if (q_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
+ return False;
+ if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
+ return False;
+
+ if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
+ return False;
+ if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
+ return False;
+
+ return True;
}
/*******************************************************************
* called from static spoolss_r_open_printer_ex (srv_spoolss.c)
* called from spoolss_open_printer_ex (cli_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL) return False;
if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
return False;
- if (!prs_uint32("status code", ps, depth, &(r_u->status)))
+ if (!prs_werror("status code", ps, depth, &(r_u->status)))
return False;
return True;
}
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+BOOL make_spoolss_q_deleteprinterdriver(
+ TALLOC_CTX *mem_ctx,
+ SPOOL_Q_DELETEPRINTERDRIVER *q_u,
+ const char *server,
+ const char* arch,
+ const char* driver
+)
+{
+ DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
+
+ q_u->server_ptr = (server!=NULL)?1:0;
+
+ /* these must be NULL terminated or else NT4 will
+ complain about invalid parameters --jerry */
+ init_unistr2(&q_u->server, server, strlen(server)+1);
+ init_unistr2(&q_u->arch, arch, strlen(arch)+1);
+ init_unistr2(&q_u->driver, driver, strlen(driver)+1);
+
+
+ return True;
+}
+
+
/*******************************************************************
* make a structure.
********************************************************************/
+
BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
const POLICY_HND *handle,
- const UNISTR2 *valuename,
- uint32 size)
+ UNISTR2 *valuename, uint32 size)
{
if (q_u == NULL) return False;
return True;
}
-
/*******************************************************************
* read a structure.
* called from spoolss_q_getprinterdata (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
{
- if (q_u == NULL) return False;
+ if (q_u == NULL)
+ return False;
prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
depth++;
if (!prs_align(ps))
return False;
- if (!smb_io_pol_hnd("printer handle",&(q_u->handle),ps,depth))
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("size", ps, depth, &q_u->size))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * read a structure.
+ * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_q_deleteprinterdata(char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL)
return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
+ depth++;
+
if (!prs_align(ps))
return False;
- if (!smb_io_unistr2("valuename", &(q_u->valuename),True,ps,depth))
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
return False;
if (!prs_align(ps))
return False;
- if (!prs_uint32("size", ps, depth, &(q_u->size)))
+ if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_r_deleteprinterdata(char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
+ depth++;
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* write a structure.
* called from spoolss_r_getprinterdata (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL)
if (!prs_uint32("needed", ps, depth, &r_u->needed))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
* make a structure.
********************************************************************/
+
BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
{
if (q_u == NULL) return False;
DEBUG(5,("make_spoolss_q_closeprinter\n"));
- memcpy(&(q_u->handle), hnd, sizeof(q_u->handle));
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
return True;
}
/*******************************************************************
* read a structure.
- * called from static spoolss_q_deleteprinter (srv_spoolss.c)
- * called from spoolss_deleteprinter (cli_spoolss.c)
+ * called from static spoolss_q_abortprinter (srv_spoolss.c)
+ * called from spoolss_abortprinter (cli_spoolss.c)
********************************************************************/
-BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
- prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
+ prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
depth++;
if (!prs_align(ps))
/*******************************************************************
* write a structure.
- * called from static spoolss_r_deleteprinter (srv_spoolss.c)
- * called from spoolss_deleteprinter (cli_spoolss.c)
+ * called from spoolss_r_abortprinter (srv_spoolss.c)
********************************************************************/
-BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
+ prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
depth++;
-
- if (!prs_align(ps))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
- if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
- return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
- return False;
-
return True;
}
-
/*******************************************************************
* read a structure.
- * called from static spoolss_q_closeprinter (srv_spoolss.c)
- * called from spoolss_closeprinter (cli_spoolss.c)
+ * called from static spoolss_q_deleteprinter (srv_spoolss.c)
+ * called from spoolss_deleteprinter (cli_spoolss.c)
********************************************************************/
-BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
- prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
+ prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
depth++;
if (!prs_align(ps))
/*******************************************************************
* write a structure.
- * called from static spoolss_r_closeprinter (srv_spoolss.c)
- * called from spoolss_closeprinter (cli_spoolss.c)
+ * called from static spoolss_r_deleteprinter (srv_spoolss.c)
+ * called from spoolss_deleteprinter (cli_spoolss.c)
********************************************************************/
+
+BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
+ return False;
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ * read a structure.
+ * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
+ * called from spoolss_deleteprinterdriver (cli_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_q_deleteprinterdriver(char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
+ return False;
+ if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
+ return False;
+ if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
+ return False;
+ if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
+ return False;
+
+
+ return True;
+}
+
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+BOOL spoolss_io_r_deleteprinterdriver(char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+
+
+/*******************************************************************
+ * read a structure.
+ * called from static spoolss_q_closeprinter (srv_spoolss.c)
+ * called from spoolss_closeprinter (cli_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ * called from static spoolss_r_closeprinter (srv_spoolss.c)
+ * called from spoolss_closeprinter (cli_spoolss.c)
+ ********************************************************************/
+
BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_startdocprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("printer handle",&(q_u->handle),ps,depth))
+ if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
return False;
- if(!smb_io_doc_info_container("",&(q_u->doc_info_container), ps, depth))
+ if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
return False;
return True;
* write a structure.
* called from spoolss_r_startdocprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_startdocprinter(char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
depth++;
if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_enddocprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_enddocprinter(char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
* write a structure.
* called from spoolss_r_enddocprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_enddocprinter(char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
depth++;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_startpageprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_startpageprinter(char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
* write a structure.
* called from spoolss_r_startpageprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_startpageprinter(char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
depth++;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_endpageprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_endpageprinter(char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
* write a structure.
* called from spoolss_r_endpageprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_endpageprinter(char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
depth++;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_writeprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_writeprinter(char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
if (q_u->buffer_size!=0)
{
- q_u->buffer=(uint8 *)malloc(q_u->buffer_size*sizeof(uint8));
+ if (UNMARSHALLING(ps))
+ q_u->buffer=(uint8 *)prs_alloc_mem(ps,q_u->buffer_size*sizeof(uint8));
if(q_u->buffer == NULL)
return False;
if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
* write a structure.
* called from spoolss_r_writeprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_writeprinter(char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
depth++;
if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_rffpcnex (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
if (q_u->option_ptr!=0) {
if (UNMARSHALLING(ps))
- if((q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
+ if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
return False;
if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
* write a structure.
* called from spoolss_r_rffpcnex (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_rffpcnex(char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
depth++;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_q_rfnpcnex (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
if (q_u->option_ptr!=0) {
if (UNMARSHALLING(ps))
- if((q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
+ if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
return False;
if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
* write a structure.
* called from spoolss_r_rfnpcnex (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_rfnpcnex(char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
* return the length of a uint16 (obvious, but the code is clean)
********************************************************************/
+
static uint32 size_of_uint16(uint16 *value)
{
return (sizeof(*value));
/*******************************************************************
* return the length of a uint32 (obvious, but the code is clean)
********************************************************************/
+
static uint32 size_of_uint32(uint32 *value)
{
return (sizeof(*value));
}
+
+/*******************************************************************
+ * return the length of a NTTIME (obvious, but the code is clean)
+ ********************************************************************/
+
+static uint32 size_of_nttime(NTTIME *value)
+{
+ return (sizeof(*value));
+}
+
/*******************************************************************
* return the length of a UNICODE string in number of char, includes:
* - the leading zero
* - the relative pointer size
********************************************************************/
+
static uint32 size_of_relative_string(UNISTR *string)
{
uint32 size=0;
size=str_len_uni(string); /* the string length */
size=size+1; /* add the leading zero */
size=size*2; /* convert in char */
+ /* Ensure size is 4 byte multiple (prs_align is being called...). */
+ size += ((4 - (size & 3)) & 3);
size=size+4; /* add the size of the ptr */
return size;
/*******************************************************************
* return the length of a uint32 (obvious, but the code is clean)
********************************************************************/
+
static uint32 size_of_device_mode(DEVICEMODE *devmode)
{
if (devmode==NULL)
/*******************************************************************
* return the length of a uint32 (obvious, but the code is clean)
********************************************************************/
+
static uint32 size_of_systemtime(SYSTEMTIME *systime)
{
if (systime==NULL)
* write a UNICODE string.
* used by all the RPC structs passing a buffer
********************************************************************/
+
static BOOL spoolss_smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
{
if (uni == NULL)
prs_debug(ps, depth, desc, "spoolss_smb_io_unistr");
depth++;
+
+ /* there should be no align here as it can mess up
+ parsing a NEW_BUFFER->prs */
+#if 0 /* JERRY */
+ if (!prs_align(ps))
+ return False;
+#endif
+
if (!prs_unistr("unistr", ps, depth, uni))
return False;
return True;
}
-
/*******************************************************************
* write a UNICODE string and its relative pointer.
* used by all the RPC structs passing a buffer
* first get in touch with me: jfm@samba.org
*
********************************************************************/
-static BOOL new_smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string)
+
+static BOOL smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string)
{
prs_struct *ps=&buffer->prs;
uint32 struct_offset = prs_offset(ps);
uint32 relative_offset;
- buffer->string_at_end -= 2*(str_len_uni(string)+1);
+ buffer->string_at_end -= (size_of_relative_string(string) - 4);
if(!prs_set_offset(ps, buffer->string_at_end))
return False;
+ if (!prs_align(ps))
+ return False;
+ buffer->string_at_end = prs_offset(ps);
/* write the string */
- if (!spoolss_smb_io_unistr(desc, string, ps, depth))
+ if (!smb_io_unistr(desc, string, ps, depth))
return False;
if(!prs_set_offset(ps, struct_offset))
return True;
}
-
/*******************************************************************
* write a array of UNICODE strings and its relative pointer.
* used by 2 RPC structs
********************************************************************/
-static BOOL new_smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, uint16 **string)
+
+static BOOL smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, uint16 **string)
{
UNISTR chaine;
while (*q!=0)
q++;
+ /* Yes this should be malloc not talloc. Don't change. */
+
+ chaine.buffer = malloc((q-p+1)*sizeof(uint16));
+ if (chaine.buffer == NULL)
+ return False;
+
memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16));
buffer->string_at_end -= (q-p+1)*sizeof(uint16);
- if(!prs_set_offset(ps, buffer->string_at_end))
+ if(!prs_set_offset(ps, buffer->string_at_end)) {
+ SAFE_FREE(chaine.buffer);
return False;
+ }
/* write the string */
- if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth))
+ if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth)) {
+ SAFE_FREE(chaine.buffer);
return False;
+ }
q++;
p=q;
+ SAFE_FREE(chaine.buffer);
}
if(!prs_set_offset(ps, struct_offset))
/* write its offset */
if (!prs_uint32("offset", ps, depth, &relative_offset))
return False;
- }
- else {
+
+ } else {
+
+ /* UNMARSHALLING */
+
uint32 old_offset;
uint16 *chaine2=NULL;
int l_chaine=0;
int l_chaine2=0;
-
+ size_t realloc_size = 0;
+
*string=NULL;
/* read the offset */
return False;
l_chaine=str_len_uni(&chaine);
- if((chaine2=(uint16 *)Realloc(chaine2, (l_chaine2+l_chaine+1)*sizeof(uint16))) == NULL)
- return False;
- memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
- l_chaine2+=l_chaine+1;
+
+ /* we're going to add two more bytes here in case this
+ is the last string in the array and we need to add
+ an extra NULL for termination */
+ if (l_chaine > 0)
+ {
+ uint16 *tc2;
+
+ realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16);
+
+ /* Yes this should be realloc - it's freed below. JRA */
+
+ if((tc2=(uint16 *)Realloc(chaine2, realloc_size)) == NULL) {
+ SAFE_FREE(chaine2);
+ return False;
+ }
+ else chaine2 = tc2;
+ memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
+ l_chaine2+=l_chaine+1;
+ }
} while(l_chaine!=0);
- *string=chaine2;
+ /* the end should be bould NULL terminated so add
+ the second one here */
+ if (chaine2)
+ {
+ chaine2[l_chaine2] = '\0';
+ *string=(uint16 *)talloc_memdup(prs_get_mem_context(ps),chaine2,realloc_size);
+ SAFE_FREE(chaine2);
+ }
if(!prs_set_offset(ps, old_offset))
return False;
return True;
}
-
/*******************************************************************
Parse a DEVMODE structure and its relative pointer.
********************************************************************/
-static BOOL new_smb_io_relsecdesc(char *desc, NEW_BUFFER *buffer, int depth,
- SEC_DESC **secdesc)
+
+static BOOL smb_io_relsecdesc(char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc)
{
prs_struct *ps= &buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_relsecdesc");
+ prs_debug(ps, depth, desc, "smb_io_relsecdesc");
depth++;
if (MARSHALLING(ps)) {
}
if (*secdesc != NULL) {
-#if 0 /* JRATEST */
- if(!prs_set_offset(ps, 0x54))
- return False;
-#else
buffer->string_at_end -= sec_desc_size(*secdesc);
if(!prs_set_offset(ps, buffer->string_at_end))
return False;
-#endif
/* write the secdesc */
if (!sec_io_desc(desc, secdesc, ps, depth))
return False;
relative_offset=buffer->string_at_end - buffer->struct_start;
/* write its offset */
-#if 0 /* JRATEST */
- relative_offset = 0x54;
-#endif
if (!prs_uint32("offset", ps, depth, &relative_offset))
return False;
/*******************************************************************
Parse a DEVMODE structure and its relative pointer.
********************************************************************/
-static BOOL new_smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
+
+static BOOL smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
{
prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_reldevmode");
+ prs_debug(ps, depth, desc, "smb_io_reldevmode");
depth++;
if (MARSHALLING(ps)) {
return False;
/* read the string */
- if((*devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL)
+ if((*devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE))) == NULL)
return False;
if (!spoolss_io_devmode(desc, ps, depth, *devmode))
return False;
return True;
}
-
/*******************************************************************
Parse a PRINTER_INFO_0 structure.
********************************************************************/
-BOOL new_smb_io_printer_info_0(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
+
+BOOL smb_io_printer_info_0(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printer_info_0");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
return False;
- if (!new_smb_io_relstr("servername", buffer, depth, &info->servername))
+ if (!smb_io_relstr("servername", buffer, depth, &info->servername))
return False;
if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
/*******************************************************************
Parse a PRINTER_INFO_1 structure.
********************************************************************/
-BOOL new_smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
+
+BOOL smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
{
prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_info_1");
+ prs_debug(ps, depth, desc, "smb_io_printer_info_1");
depth++;
buffer->struct_start=prs_offset(ps);
if (!prs_uint32("flags", ps, depth, &info->flags))
return False;
- if (!new_smb_io_relstr("description", buffer, depth, &info->description))
+ if (!smb_io_relstr("description", buffer, depth, &info->description))
return False;
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
- if (!new_smb_io_relstr("comment", buffer, depth, &info->comment))
+ if (!smb_io_relstr("comment", buffer, depth, &info->comment))
return False;
return True;
/*******************************************************************
Parse a PRINTER_INFO_2 structure.
********************************************************************/
-BOOL new_smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
+
+BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
{
- uint32 sec_offset;
prs_struct *ps=&buffer->prs;
- int i = 0;
- prs_debug(ps, depth, desc, "new_smb_io_printer_info_2");
+ prs_debug(ps, depth, desc, "smb_io_printer_info_2");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("servername", buffer, depth, &info->servername))
+ if (!smb_io_relstr("servername", buffer, depth, &info->servername))
return False;
- if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
return False;
- if (!new_smb_io_relstr("sharename", buffer, depth, &info->sharename))
+ if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
return False;
- if (!new_smb_io_relstr("portname", buffer, depth, &info->portname))
+ if (!smb_io_relstr("portname", buffer, depth, &info->portname))
return False;
- if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
+ if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
return False;
- if (!new_smb_io_relstr("comment", buffer, depth, &info->comment))
+ if (!smb_io_relstr("comment", buffer, depth, &info->comment))
return False;
- if (!new_smb_io_relstr("location", buffer, depth, &info->location))
+ if (!smb_io_relstr("location", buffer, depth, &info->location))
return False;
/* NT parses the DEVMODE at the end of the struct */
- if (!new_smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
+ if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
return False;
- if (!new_smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
+ if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
return False;
- if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
+ if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
return False;
- if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
return False;
- if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
+ if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
return False;
- if (!prs_uint32_pre("secdesc_ptr ", ps, depth, &i, &sec_offset))
+ if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
return False;
if (!prs_uint32("attributes", ps, depth, &info->attributes))
if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
return False;
- if (!prs_uint32_post("secdesc_ptr", ps, depth, &i, sec_offset, info->secdesc ? prs_offset(ps) : 0 ))
+#if 0 /* JFMTEST */
+ if (!prs_uint32_post("secdesc_ptr", ps, depth, NULL, sec_offset, info->secdesc ? prs_offset(ps)-buffer->struct_start : 0 ))
return False;
if (!sec_io_desc("secdesc", &info->secdesc, ps, depth))
return False;
-
+#endif
return True;
}
/*******************************************************************
Parse a PRINTER_INFO_3 structure.
********************************************************************/
-BOOL new_smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
+
+BOOL smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_info_3");
+ prs_debug(ps, depth, desc, "smb_io_printer_info_3");
depth++;
buffer->struct_start=prs_offset(ps);
}
/*******************************************************************
- Parse a PRINTER_INFO_3 structure.
+ Parse a PRINTER_INFO_4 structure.
+********************************************************************/
+
+BOOL smb_io_printer_info_4(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
+{
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_printer_info_4");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!smb_io_relstr("servername", buffer, depth, &info->servername))
+ return False;
+ if (!prs_uint32("attributes", ps, depth, &info->attributes))
+ return False;
+ return True;
+}
+
+/*******************************************************************
+ Parse a PRINTER_INFO_5 structure.
+********************************************************************/
+
+BOOL smb_io_printer_info_5(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
+{
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_printer_info_5");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!smb_io_relstr("portname", buffer, depth, &info->portname))
+ return False;
+ if (!prs_uint32("attributes", ps, depth, &info->attributes))
+ return False;
+ if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
+ return False;
+ if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
+ return False;
+ return True;
+}
+
+/*******************************************************************
+ Parse a PORT_INFO_1 structure.
+********************************************************************/
+
+BOOL smb_io_port_info_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
+{
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_port_info_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Parse a PORT_INFO_2 structure.
********************************************************************/
-BOOL new_smb_io_port_info_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
+
+BOOL smb_io_port_info_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_info_3");
+ prs_debug(ps, depth, desc, "smb_io_port_info_2");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
return False;
- if (!new_smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
+ if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
return False;
- if (!new_smb_io_relstr("description", buffer, depth, &info->description))
+ if (!smb_io_relstr("description", buffer, depth, &info->description))
return False;
if (!prs_uint32("port_type", ps, depth, &info->port_type))
return False;
/*******************************************************************
Parse a DRIVER_INFO_1 structure.
********************************************************************/
-BOOL new_smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
+
+BOOL smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_1");
+ prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
return True;
}
-
/*******************************************************************
Parse a DRIVER_INFO_2 structure.
********************************************************************/
-BOOL new_smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
+
+BOOL smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_2");
+ prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
depth++;
buffer->struct_start=prs_offset(ps);
if (!prs_uint32("version", ps, depth, &info->version))
return False;
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
- if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
+ if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
return False;
- if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
+ if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
return False;
- if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
+ if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
return False;
- if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
+ if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
return False;
return True;
}
-
/*******************************************************************
Parse a DRIVER_INFO_3 structure.
********************************************************************/
-BOOL new_smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
+
+BOOL smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_3");
+ prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
depth++;
buffer->struct_start=prs_offset(ps);
if (!prs_uint32("version", ps, depth, &info->version))
return False;
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
- if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
+ if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
return False;
- if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
+ if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
return False;
- if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
+ if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
return False;
- if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
+ if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
return False;
- if (!new_smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
+ if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
return False;
- if (!new_smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
+ if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
return False;
- if (!new_smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
+ if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
return False;
- if (!new_smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
+ if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
return False;
return True;
}
-
/*******************************************************************
- Parse a JOB_INFO_1 structure.
-********************************************************************/
-BOOL new_smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
+ Parse a DRIVER_INFO_6 structure.
+********************************************************************/
+
+BOOL smb_io_printer_driver_info_6(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_job_info_1");
+ prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!prs_uint32("jobid", ps, depth, &info->jobid))
+ if (!prs_uint32("version", ps, depth, &info->version))
return False;
- if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
- if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
+ if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
return False;
- if (!new_smb_io_relstr("username", buffer, depth, &info->username))
+ if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
return False;
- if (!new_smb_io_relstr("document", buffer, depth, &info->document))
+ if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
return False;
- if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
return False;
- if (!new_smb_io_relstr("text_status", buffer, depth, &info->text_status))
+ if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
return False;
- if (!prs_uint32("status", ps, depth, &info->status))
+
+ if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
return False;
- if (!prs_uint32("priority", ps, depth, &info->priority))
+
+ if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
return False;
- if (!prs_uint32("position", ps, depth, &info->position))
+ if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
return False;
- if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
+
+ if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
return False;
- if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
+
+ if (!prs_uint32("date.low", ps, depth, &info->driver_date.low))
return False;
- if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
+ if (!prs_uint32("date.high", ps, depth, &info->driver_date.high))
return False;
- return True;
-}
+ if (!prs_uint32("padding", ps, depth, &info->padding))
+ return False;
-/*******************************************************************
- Parse a JOB_INFO_2 structure.
-********************************************************************/
-BOOL new_smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
-{
- uint pipo=0;
- prs_struct *ps=&(buffer->prs);
-
- prs_debug(ps, depth, desc, "new_smb_io_job_info_2");
+ if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
+ return False;
+
+ if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
+ return False;
+
+ if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
+ return False;
+ if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
+ return False;
+ if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
+ return False;
+ if (!smb_io_relstr("provider", buffer, depth, &info->provider))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Parse a JOB_INFO_1 structure.
+********************************************************************/
+
+BOOL smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
+{
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_job_info_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("jobid", ps, depth, &info->jobid))
+ return False;
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
+ return False;
+ if (!smb_io_relstr("username", buffer, depth, &info->username))
+ return False;
+ if (!smb_io_relstr("document", buffer, depth, &info->document))
+ return False;
+ if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ return False;
+ if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
+ return False;
+ if (!prs_uint32("status", ps, depth, &info->status))
+ return False;
+ if (!prs_uint32("priority", ps, depth, &info->priority))
+ return False;
+ if (!prs_uint32("position", ps, depth, &info->position))
+ return False;
+ if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
+ return False;
+ if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
+ return False;
+ if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Parse a JOB_INFO_2 structure.
+********************************************************************/
+
+BOOL smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
+{
+ uint32 pipo=0;
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_job_info_2");
depth++;
buffer->struct_start=prs_offset(ps);
if (!prs_uint32("jobid",ps, depth, &info->jobid))
return False;
- if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ if (!smb_io_relstr("printername", buffer, depth, &info->printername))
return False;
- if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
+ if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
return False;
- if (!new_smb_io_relstr("username", buffer, depth, &info->username))
+ if (!smb_io_relstr("username", buffer, depth, &info->username))
return False;
- if (!new_smb_io_relstr("document", buffer, depth, &info->document))
+ if (!smb_io_relstr("document", buffer, depth, &info->document))
return False;
- if (!new_smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
+ if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
return False;
- if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
return False;
- if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
+ if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
return False;
- if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
+ if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
return False;
- if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
+ if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
return False;
- if (!new_smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
+ if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
return False;
- if (!new_smb_io_relstr("text_status", buffer, depth, &info->text_status))
+ if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
return False;
/* SEC_DESC sec_desc;*/
/*******************************************************************
********************************************************************/
-BOOL new_smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth)
+
+BOOL smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_form_1");
+ prs_debug(ps, depth, desc, "smb_io_form_1");
depth++;
buffer->struct_start=prs_offset(ps);
if (!prs_uint32("flag", ps, depth, &info->flag))
return False;
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
if (!prs_uint32("width", ps, depth, &info->width))
/*******************************************************************
Read/write a BUFFER struct.
********************************************************************/
-static BOOL new_spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUFFER *buffer)
+
+static BOOL spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer)
{
- if (buffer == NULL)
- return False;
+ NEW_BUFFER *buffer = *pp_buffer;
- prs_debug(ps, depth, desc, "new_spoolss_io_buffer");
+ prs_debug(ps, depth, desc, "spoolss_io_buffer");
depth++;
+ if (UNMARSHALLING(ps))
+ buffer = *pp_buffer = (NEW_BUFFER *)prs_alloc_mem(ps, sizeof(NEW_BUFFER));
+
+ if (buffer == NULL)
+ return False;
+
if (!prs_uint32("ptr", ps, depth, &buffer->ptr))
return False;
buffer->string_at_end=0;
if (buffer->ptr==0) {
- if (!prs_init(&buffer->prs, 0, 4, UNMARSHALL))
+ /*
+ * JRA. I'm not sure if the data in here is in big-endian format if
+ * the client is big-endian. Leave as default (little endian) for now.
+ */
+
+ if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL))
return False;
return True;
}
if (!prs_uint32("size", ps, depth, &buffer->size))
return False;
- if (!prs_init(&buffer->prs, buffer->size, 4, UNMARSHALL))
+ /*
+ * JRA. I'm not sure if the data in here is in big-endian format if
+ * the client is big-endian. Leave as default (little endian) for now.
+ */
+
+ if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL))
return False;
if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size))
return True;
}
else {
+ BOOL ret = False;
+
/* writing */
- if (buffer->ptr==0)
+ if (buffer->ptr==0) {
+ /* We have finished with the data in buffer->prs - free it. */
+ prs_mem_free(&buffer->prs);
return True;
-
+ }
+
if (!prs_uint32("size", ps, depth, &buffer->size))
- return False;
+ goto out;
+
if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size))
- return False;
+ goto out;
- return True;
+ ret = True;
+ out:
+
+ /* We have finished with the data in buffer->prs - free it. */
+ prs_mem_free(&buffer->prs);
+
+ return ret;
}
}
/*******************************************************************
move a BUFFER from the query to the reply.
+ As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
+ this is ok. This is an OPTIMIZATION and is not strictly neccessary.
+ Clears the memory to zero also.
********************************************************************/
-void new_spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
+
+void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
{
prs_switch_type(&src->prs, MARSHALL);
if(!prs_set_offset(&src->prs, 0))
return;
- prs_force_dynamic(&(src->prs));
-
+ prs_force_dynamic(&src->prs);
+ prs_mem_clear(&src->prs);
*dest=src;
}
-/*******************************************************************
- create a BUFFER struct.
-********************************************************************/
-BOOL new_spoolss_allocate_buffer(NEW_BUFFER **buffer)
-{
- if (buffer==NULL)
- return False;
-
- if((*buffer=(NEW_BUFFER *)malloc(sizeof(NEW_BUFFER))) == NULL) {
- DEBUG(0,("new_spoolss_allocate_buffer: malloc fail for size %u.\n",
- (unsigned int)sizeof(NEW_BUFFER) ));
- return False;
- }
-
- (*buffer)->ptr=0x0;
- (*buffer)->size=0;
- (*buffer)->string_at_end=0;
- return True;
-}
-
-/*******************************************************************
- Destroy a BUFFER struct.
-********************************************************************/
-void new_spoolss_free_buffer(NEW_BUFFER *buffer)
-{
- if (buffer==NULL)
- return;
-
- prs_mem_free(&buffer->prs);
- buffer->ptr=0x0;
- buffer->size=0;
- buffer->string_at_end=0;
-
- free(buffer);
-}
-
/*******************************************************************
Get the size of a BUFFER struct.
********************************************************************/
+
uint32 new_get_buffer_size(NEW_BUFFER *buffer)
{
return (buffer->size);
}
-
/*******************************************************************
Parse a DRIVER_DIRECTORY_1 structure.
********************************************************************/
-BOOL new_smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
+
+BOOL smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_driverdir_1");
+ prs_debug(ps, depth, desc, "smb_io_driverdir_1");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!spoolss_smb_io_unistr(desc, &info->name, ps, depth))
+ if (!smb_io_unistr(desc, &info->name, ps, depth))
return False;
return True;
/*******************************************************************
Parse a PORT_INFO_1 structure.
********************************************************************/
-BOOL new_smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
+
+BOOL smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_port_1");
+ prs_debug(ps, depth, desc, "smb_io_port_1");
depth++;
buffer->struct_start=prs_offset(ps);
- if(!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
return False;
return True;
/*******************************************************************
Parse a PORT_INFO_2 structure.
********************************************************************/
-BOOL new_smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
+
+BOOL smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
- prs_debug(ps, depth, desc, "new_smb_io_port_2");
+ prs_debug(ps, depth, desc, "smb_io_port_2");
depth++;
buffer->struct_start=prs_offset(ps);
- if(!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
return False;
- if(!new_smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
+ if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
return False;
- if(!new_smb_io_relstr("description", buffer, depth, &info->description))
+ if(!smb_io_relstr("description", buffer, depth, &info->description))
return False;
if(!prs_uint32("port_type", ps, depth, &info->port_type))
return False;
return True;
}
-
/*******************************************************************
********************************************************************/
+
BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
depth++;
buffer->struct_start=prs_offset(ps);
- if (new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (smb_io_relstr("name", buffer, depth, &info->name))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL smb_io_printprocdatatype_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1");
depth++;
buffer->struct_start=prs_offset(ps);
- if (new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (smb_io_relstr("name", buffer, depth, &info->name))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL smb_io_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
{
prs_struct *ps=&buffer->prs;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL smb_io_printmonitor_info_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
{
- prs_struct *ps=&(buffer->prs);
+ prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
depth++;
buffer->struct_start=prs_offset(ps);
- if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ if (!smb_io_relstr("name", buffer, depth, &info->name))
return False;
- if (!new_smb_io_relstr("environment", buffer, depth, &info->environment))
+ if (!smb_io_relstr("environment", buffer, depth, &info->environment))
return False;
- if (!new_smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
+ if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
return False;
return True;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
{
uint32 size=0;
size += 4;
/* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
size += sec_desc_size( info->secdesc );
-
+
size+=size_of_device_mode( info->devmode );
size+=size_of_relative_string( &info->servername );
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
+uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
+{
+ uint32 size=0;
+
+ size+=size_of_relative_string( &info->printername );
+ size+=size_of_relative_string( &info->servername );
+
+ size+=size_of_uint32( &info->attributes );
+ return size;
+}
+
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+
+uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
+{
+ uint32 size=0;
+
+ size+=size_of_relative_string( &info->printername );
+ size+=size_of_relative_string( &info->portname );
+
+ size+=size_of_uint32( &info->attributes );
+ size+=size_of_uint32( &info->device_not_selected_timeout );
+ size+=size_of_uint32( &info->transmission_retry_timeout );
+ return size;
+}
+
+
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+
uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
{
/* The 4 is for the self relative pointer.. */
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
{
int size=0;
return size;
}
+/*******************************************************************
+return the size required by a string array.
+********************************************************************/
+
+uint32 spoolss_size_string_array(uint16 *string)
+{
+ uint32 i = 0;
+
+ if (string) {
+ for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
+ }
+ i=i+2; /* to count all chars including the leading zero */
+ i=2*i; /* because we need the value in bytes */
+ i=i+4; /* the offset pointer size */
+
+ return i;
+}
+
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
{
int size=0;
- uint16 *string;
- int i=0;
size+=size_of_uint32( &info->version );
size+=size_of_relative_string( &info->name );
size+=size_of_relative_string( &info->monitorname );
size+=size_of_relative_string( &info->defaultdatatype );
- string=info->dependentfiles;
- if (string) {
- for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
- }
+ size+=spoolss_size_string_array(info->dependentfiles);
- i=i+2; /* to count all chars including the leading zero */
- i=2*i; /* because we need the value in bytes */
- i=i+4; /* the offset pointer size */
+ return size;
+}
+
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+
+uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
+{
+ uint32 size=0;
+
+ size+=size_of_uint32( &info->version );
+ size+=size_of_relative_string( &info->name );
+ size+=size_of_relative_string( &info->architecture );
+ size+=size_of_relative_string( &info->driverpath );
+ size+=size_of_relative_string( &info->datafile );
+ size+=size_of_relative_string( &info->configfile );
+ size+=size_of_relative_string( &info->helpfile );
+
+ size+=spoolss_size_string_array(info->dependentfiles);
+
+ size+=size_of_relative_string( &info->monitorname );
+ size+=size_of_relative_string( &info->defaultdatatype );
+
+ size+=spoolss_size_string_array(info->previousdrivernames);
- size+=i;
+ size+=size_of_nttime(&info->driver_date);
+ size+=size_of_uint32( &info->padding );
+ size+=size_of_uint32( &info->driver_version_low );
+ size+=size_of_uint32( &info->driver_version_high );
+ size+=size_of_relative_string( &info->mfgname );
+ size+=size_of_relative_string( &info->oem_url );
+ size+=size_of_relative_string( &info->hardware_id );
+ size+=size_of_relative_string( &info->provider );
return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_form_1(FORM_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
+uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
+{
+ int size=0;
+
+ size=str_len_uni(&info->name); /* the string length */
+ size=size+1; /* add the leading zero */
+ size=size*2; /* convert in char */
+
+ return size;
+}
+
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+
uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
+{
+ uint32 size = 0;
+
+ if (!p)
+ return 0;
+
+ /* uint32(offset) + uint32(length) + length) */
+ size += (size_of_uint32(&p->value_len)*2) + p->value_len;
+ size += (size_of_uint32(&p->data_len)*2) + p->data_len;
+
+ size += size_of_uint32(&p->type);
+
+ return size;
+}
+
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+
uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
{
int size=0;
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
+
uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
{
int size=0;
/*******************************************************************
* init a structure.
********************************************************************/
+
BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
const POLICY_HND *hnd,
const fstring architecture,
* read a structure.
* called from spoolss_getprinterdriver2 (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_getprinterdriver2(char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
if(!prs_align(ps))
return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
+ if(!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if(!prs_align(ps))
* read a structure.
* called from spoolss_getprinterdriver2 (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
return False;
if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
* init a structure.
********************************************************************/
-BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, uint32 flags,
- fstring servername, uint32 level,
- NEW_BUFFER *buffer, uint32 offered)
+
+BOOL make_spoolss_q_enumprinters(
+ SPOOL_Q_ENUMPRINTERS *q_u,
+ uint32 flags,
+ fstring servername,
+ uint32 level,
+ NEW_BUFFER *buffer,
+ uint32 offered
+)
{
q_u->flags=flags;
q_u->servername_ptr = (servername != NULL) ? 1 : 0;
- init_unistr2(&(q_u->servername), servername, strlen(servername));
+ init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
q_u->level=level;
q_u->buffer=buffer;
/*******************************************************************
* init a structure.
********************************************************************/
+
BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
fstring servername, uint32 level,
NEW_BUFFER *buffer, uint32 offered)
* read a structure.
* called from spoolss_enumprinters (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
Parse a SPOOL_R_ENUMPRINTERS structure.
********************************************************************/
-BOOL new_spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "new_spoolss_io_r_enumprinters");
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
depth++;
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* called from spoolss_r_enum_printers (srv_spoolss.c)
*
********************************************************************/
+
BOOL spoolss_io_r_getprinter(char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("needed", ps, depth, &r_u->needed))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
* read a structure.
* called from spoolss_getprinter (srv_spoolss.c)
********************************************************************/
+
BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
* init a structure.
********************************************************************/
-BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u, const POLICY_HND *hnd, uint32 level,
- NEW_BUFFER *buffer, uint32 offered)
+
+BOOL make_spoolss_q_getprinter(
+ TALLOC_CTX *mem_ctx,
+ SPOOL_Q_GETPRINTER *q_u,
+ const POLICY_HND *hnd,
+ uint32 level,
+ NEW_BUFFER *buffer,
+ uint32 offered
+)
{
if (q_u == NULL)
{
}
/*******************************************************************
-********************************************************************/
-BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
- depth++;
+ * init a structure.
+ ********************************************************************/
+BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
+ const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
+ uint32 command)
+{
+ SEC_DESC *secdesc;
+ DEVICEMODE *devmode;
- if(!prs_align(ps))
+ if (q_u == NULL)
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
- return False;
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+
+ q_u->level = level;
+ q_u->info.level = level;
+ q_u->info.info_ptr = (info != NULL) ? 1 : 0;
+ switch (level) {
+
+ /* There's no such thing as a setprinter level 1 */
+
+ case 2:
+ secdesc = info->printers_2->secdesc;
+ devmode = info->printers_2->devmode;
+
+ make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
+#if 1 /* JERRY TEST */
+ q_u->secdesc_ctr = (SEC_DESC_BUF*)malloc(sizeof(SEC_DESC_BUF));
+ if (!q_u->secdesc_ctr)
+ return False;
+ q_u->secdesc_ctr->ptr = (secdesc != NULL) ? 1: 0;
+ q_u->secdesc_ctr->max_len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
+ q_u->secdesc_ctr->len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
+ q_u->secdesc_ctr->sec = secdesc;
+
+ q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
+ q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
+ q_u->devmode_ctr.devmode = devmode;
+#else
+ q_u->secdesc_ctr = NULL;
+
+ q_u->devmode_ctr.devmode_ptr = 0;
+ q_u->devmode_ctr.size = 0;
+ q_u->devmode_ctr.devmode = NULL;
+#endif
+ break;
+ default:
+ DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
+ break;
+ }
+
+
+ q_u->command = command;
return True;
}
+
/*******************************************************************
- Delete the dynamic parts of a SPOOL_Q_SETPRINTER struct.
********************************************************************/
-void free_spoolss_q_setprinter(SPOOL_Q_SETPRINTER *q_u)
-{
- free_spool_printer_info_level(&q_u->info);
- free_sec_desc_buf( &q_u->secdesc_ctr );
- free_devmode( q_u->devmode_ctr.devmode );
+BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
}
/*******************************************************************
if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
return False;
+ if(!prs_align(ps))
+ return False;
+
switch (q_u->level)
{
case 2:
{
if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
return False;
+ } else {
+ uint32 dummy = 0;
+
+ /* Parse a NULL security descriptor. This should really
+ happen inside the sec_io_desc_buf() function. */
+
+ prs_debug(ps, depth, "", "sec_io_desc_buf");
+ if (!prs_uint32("size", ps, depth + 1, &dummy))
+ return False;
+ if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
+ False;
}
if(!prs_uint32("command", ps, depth, &q_u->command))
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
{
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "");
if(!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if(!prs_align(ps))
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
}
-
/*******************************************************************
********************************************************************/
+
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
uint32 firstjob,
uint32 numofjobs,
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
+ if(!prs_align(ps))
+ return False;
+
if (!prs_uint32("offered", ps, depth, &q_u->offered))
return False;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
/*******************************************************************
Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
********************************************************************/
-BOOL new_spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "new_spoolss_io_r_enumprinterdrivers");
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
depth++;
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
* init a structure.
********************************************************************/
+
BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
const char *name,
const char *environment,
/*******************************************************************
Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
********************************************************************/
+
BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
{
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
{
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
********************************************************************/
-BOOL new_spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "new_spoolss_io_r_enumforms");
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
depth++;
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
+BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
+{
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_getform");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+ if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
+
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("offered", ps, depth, &q_u->offered))
return False;
return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
+BOOL spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_getform");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
+ return False;
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
}
/*******************************************************************
Parse a SPOOL_R_ENUMPORTS structure.
********************************************************************/
-BOOL new_spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "new_spoolss_io_r_enumports");
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
depth++;
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
********************************************************************/
+
BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
/*******************************************************************
Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
********************************************************************/
+
BOOL spool_io_printer_info_level_3(char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
/*******************************************************************
Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
********************************************************************/
+
BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
/*******************************************************************
********************************************************************/
+
BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spool_io_printer_info_level");
*/
case 0:
break;
- /*
- * level 2 is used by addprinter
- * and by setprinter when updating printer's info
- */
+ /* DOCUMENT ME!!! What is level 1 used for? */
case 1:
{
if (UNMARSHALLING(ps)) {
- if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
+ if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
return False;
- ZERO_STRUCTP(il->info_1);
}
if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
return False;
break;
}
+ /*
+ * level 2 is used by addprinter
+ * and by setprinter when updating printer's info
+ */
case 2:
if (UNMARSHALLING(ps)) {
- if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
+ if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
return False;
- ZERO_STRUCTP(il->info_2);
}
if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
return False;
break;
+ /* DOCUMENT ME!!! What is level 3 used for? */
case 3:
{
if (UNMARSHALLING(ps)) {
- if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
+ if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
return False;
- ZERO_STRUCTP(il->info_3);
}
if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
return False;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
{
+ uint32 ptr_sec_desc = 0;
+
prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
depth++;
- /*
- * I think that's one of the few well written functions.
- * the sub-structures are correctly parsed and analysed
- * the info level are handled in a nice way.
- */
-
if(!prs_align(ps))
return False;
if(!prs_uint32("", ps, depth, &q_u->server_name_ptr))
if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
return False;
- /* the 4 unknown are all 0 */
-
- /*
- * en fait ils sont pas inconnu
- * par recoupement avec rpcSetPrinter
- * c'est le devicemode
- * et le security descriptor.
- */
-
- if(!prs_uint32("unk0", ps, depth, &q_u->unk0))
- return False;
- if(!prs_uint32("unk1", ps, depth, &q_u->unk1))
- return False;
- if(!prs_uint32("unk2", ps, depth, &q_u->unk2))
+ if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
return False;
- if(!prs_uint32("unk3", ps, depth, &q_u->unk3))
+
+ if(!prs_align(ps))
return False;
+ switch (q_u->level) {
+ case 2:
+ ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
+ break;
+ case 3:
+ ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
+ break;
+ }
+ if (ptr_sec_desc) {
+ if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
+ return False;
+ } else {
+ uint32 dummy;
+
+ /* Parse a NULL security descriptor. This should really
+ happen inside the sec_io_desc_buf() function. */
+
+ prs_debug(ps, depth, "", "sec_io_desc_buf");
+ if (!prs_uint32("size", ps, depth + 1, &dummy))
+ return False;
+ if (!prs_uint32("ptr", ps, depth + 1, &dummy))
+ return False;
+ }
+
if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
return False;
if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
return True;
}
-
/*******************************************************************
********************************************************************/
-BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u, prs_struct *ps, int depth)
+
+BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u,
+ prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
depth++;
if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
prs_struct *ps, int depth)
{
/* reading */
if (UNMARSHALLING(ps)) {
- il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
+ il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
if(il == NULL)
return False;
- ZERO_STRUCTP(il);
*q_u=il;
}
else {
return True;
}
-void free_spool_printer_driver_info_level_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u)
-{
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il = *q_u;
-
- if (il == NULL)
- return;
-
- free_buffer5(&il->dependentfiles);
-
- safe_free(il);
-}
-
/*******************************************************************
parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
********************************************************************/
+
BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
prs_struct *ps, int depth)
{
/* reading */
if (UNMARSHALLING(ps)) {
- il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
+ il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
if(il == NULL)
return False;
- ZERO_STRUCTP(il);
*q_u=il;
}
else {
if(!prs_uint32("version", ps, depth, &il->version))
return False;
+
if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
- return False;
+ return False;
+ /*
+ * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
+ * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
+ * from W2K CDROM (which uses unidriver). JohnR 010205
+ */
+ if (!il->name_ptr) {
+ DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
+ if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
+ return False;
+ }
+
if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
return False;
if(!prs_uint32("driverpath_ptr", ps, depth, &il->driverpath_ptr))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
return False;
if(!prs_align(ps))
return False;
+
if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
return False;
if(!prs_align(ps))
return True;
}
-void free_spool_printer_driver_info_level_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u)
-{
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il = *q_u;
-
- if (il == NULL)
- return;
-
- free_buffer5(&il->dependentfiles);
- free_buffer5(&il->previousnames);
-
- safe_free(il);
-}
-
-
/*******************************************************************
convert a buffer of UNICODE strings null terminated
the buffer is terminated by a NULL
********************************************************************/
static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
{
- fstring f;
+ fstring f, *tar;
int n = 0;
char *src;
- if (buf5==NULL) return False;
+ if (buf5==NULL)
+ return False;
src = (char *)buf5->buffer;
*ar = NULL;
while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
- unistr_to_dos(f, src, sizeof(f)-1);
+ rpcstr_pull(f, src, sizeof(f)-1, -1, 0);
src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
- *ar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
+ tar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
+ if (!tar)
+ return False;
+ else
+ *ar = tar;
fstrcpy((*ar)[n], f);
n++;
}
fstrcpy((*ar)[n], "");
-
+
return True;
}
+
+
+
/*******************************************************************
read a UNICODE array with null terminated strings
and null terminated array
and size of array at beginning
********************************************************************/
+
BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
{
if (buffer==NULL) return False;
/*******************************************************************
********************************************************************/
+
BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
return True;
}
-void free_spool_printer_driver_info_level(SPOOL_PRINTER_DRIVER_INFO_LEVEL *il)
+/*******************************************************************
+ init a SPOOL_Q_ADDPRINTERDRIVER struct
+ ******************************************************************/
+
+BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
+ SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
+ uint32 level, PRINTER_DRIVER_CTR *info)
{
- if (il->ptr==0)
- return;
+ DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
+
+ q_u->server_name_ptr = (srv_name!=NULL)?1:0;
+ init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
+
+ q_u->level = level;
+
+ q_u->info.level = level;
+ q_u->info.ptr = (info!=NULL)?1:0;
+ switch (level)
+ {
+ /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
+ case 3 :
+ make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
+ break;
+
+ /* info level 6 is supported by WinME and Win2k */
+ case 6:
+ /* WRITEME!! will add later --jerry */
+ break;
+
+ default:
+ DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
+ break;
+ }
+
+ return True;
+}
- switch (il->level) {
- case 3:
- free_spool_printer_driver_info_level_3(&il->info_3);
- break;
- case 6:
- free_spool_printer_driver_info_level_6(&il->info_6);
- break;
+BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
+ SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
+ DRIVER_INFO_3 *info3)
+{
+ uint32 len = 0;
+ uint16 *ptr = info3->dependentfiles;
+ BOOL done = False;
+ BOOL null_char = False;
+ SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
+
+ if (!(inf=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)talloc_zero(mem_ctx, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3))))
+ return False;
+
+ inf->cversion = info3->version;
+ inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
+ inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
+ inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
+ inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
+ inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
+ inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
+ inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
+ inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
+
+ init_unistr2_from_unistr(&inf->name, &info3->name);
+ init_unistr2_from_unistr(&inf->environment, &info3->architecture);
+ init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
+ init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
+ init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
+ init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
+ init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
+ init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
+
+ while (!done)
+ {
+ switch (*ptr)
+ {
+ case 0:
+ /* the null_char BOOL is used to help locate
+ two '\0's back to back */
+ if (null_char)
+ done = True;
+ else
+ null_char = True;
+ break;
+
+ default:
+ null_char = False;
+ ;;
+ break;
+ }
+ len++;
+ ptr++;
+ }
+ inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
+ inf->dependentfilessize = len;
+ if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles))
+ {
+ SAFE_FREE(inf);
+ return False;
+ }
+
+ *spool_drv_info = inf;
+
+ return True;
+}
+
+/*******************************************************************
+ make a BUFFER5 struct from a uint16*
+ ******************************************************************/
+BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src)
+{
+
+ buf5->buf_len = len;
+ if((buf5->buffer=(uint16*)talloc_memdup(mem_ctx, src, sizeof(uint16)*len)) == NULL)
+ {
+ DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
+ return False;
}
+
+ return True;
}
/*******************************************************************
-********************************************************************/
+ fill in the prs_struct for a ADDPRINTERDRIVER request PDU
+ ********************************************************************/
+
BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
}
/*******************************************************************
- Free the dynamic parts of a printer driver.
********************************************************************/
-void free_spoolss_q_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u)
+BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
{
- free_spool_printer_driver_info_level(&q_u->info);
-}
+ prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
+ depth++;
-/*******************************************************************
-********************************************************************/
-BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
- depth++;
-
- if(!prs_uint32("status", ps, depth, &q_u->status))
+ if(!prs_werror("status", ps, depth, &q_u->status))
return False;
return True;
}
-
/*******************************************************************
********************************************************************/
+
BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
{
DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
- uniarray_2_dosarray(&(uni->dependentfiles), &(d->dependentfiles) );
-
- return True;
+ if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
+ return True;
+
+ SAFE_FREE(*asc);
+ return False;
}
/*******************************************************************
DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
- uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles );
- uniarray_2_dosarray(&uni->previousnames, &d->previousnames );
-
+ if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
+ goto error;
+ if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames ))
+ goto error;
+
return True;
+
+error:
+ SAFE_FREE(*asc);
+ return False;
}
BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
DEBUG(7,("Converting from UNICODE to ASCII\n"));
time_unix=time(NULL);
- if (*asc==NULL)
- {
+ if (*asc==NULL) {
DEBUGADD(8,("allocating memory\n"));
*asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
+ unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
/*******************************************************************
* init a structure.
********************************************************************/
+
BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
fstring servername, fstring env_name, uint32 level,
NEW_BUFFER *buffer, uint32 offered)
{
init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
-
init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
- q_u->level=level;
- q_u->buffer=buffer;
- q_u->offered=offered;
+ q_u->level=level;
+ q_u->buffer=buffer;
+ q_u->offered=offered;
- return True;
+ return True;
}
-
/*******************************************************************
Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
********************************************************************/
+
BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
if(!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if(!prs_align(ps))
/*******************************************************************
Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
********************************************************************/
+
BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("needed", ps, depth, &r_u->needed))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
********************************************************************/
+
+BOOL spoolss_io_q_addprintprocessor(char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
+ return False;
+ if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("path", &q_u->path, True, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
+BOOL spoolss_io_r_addprintprocessor(char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
BOOL spoolss_io_r_enumprintprocdatatypes(char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumprintprocdatatypes(char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("buffer", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
********************************************************************/
+
BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
if (!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if (!prs_align(ps))
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("returned", ps, depth, &r_u->returned))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
return False;
if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
return False;
- if(!prs_uint16s(False, "value", ps, depth, r_u->value, r_u->valuesize))
+
+ if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
+ return False;
+
+ if(!prs_align(ps))
return False;
+
if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
return False;
return False;
if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
return False;
+ if(!prs_align(ps))
+ return False;
+
if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
/*******************************************************************
********************************************************************/
+
BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
const POLICY_HND *hnd,
uint32 idx, uint32 valuelen, uint32 datalen)
/*******************************************************************
********************************************************************/
+BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, TALLOC_CTX *ctx, const POLICY_HND *hnd,
+ char* value, char* data)
+{
+ UNISTR2 tmp;
+
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+ q_u->type = REG_SZ;
+ init_unistr2(&q_u->value, value, strlen(value)+1);
+
+ init_unistr2(&tmp, data, strlen(data)+1);
+ q_u->max_len = q_u->real_len = tmp.uni_max_len*2;
+ q_u->data = talloc(ctx, q_u->real_len);
+ memcpy(q_u->data, tmp.buffer, q_u->real_len);
+
+ return True;
+}
+/*******************************************************************
+********************************************************************/
+
BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
switch (q_u->type)
{
- case 0x1:
- case 0x3:
- case 0x4:
- case 0x7:
- q_u->data=(uint8 *)malloc(q_u->max_len * sizeof(uint8));
- if(q_u->data == NULL)
- return False;
- if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
- return False;
+ case REG_SZ:
+ case REG_BINARY:
+ case REG_DWORD:
+ case REG_MULTI_SZ:
+ if (q_u->max_len) {
+ if (UNMARSHALLING(ps))
+ q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
+ if(q_u->data == NULL)
+ return False;
+ if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
+ return False;
+ }
if(!prs_align(ps))
return False;
break;
return True;
}
-void free_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u)
+/*******************************************************************
+********************************************************************/
+
+BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
{
- safe_free(q_u->data);
+ prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
}
/*******************************************************************
********************************************************************/
-BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
+BOOL spoolss_io_q_resetprinter(char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
+ prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
+ return False;
+
+ if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr))
+ return False;
+
+ if (q_u->datatype_ptr) {
+ if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth))
+ return False;
+ }
+
+ if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+********************************************************************/
+BOOL spoolss_io_r_resetprinter(char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
*param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM));
if(*param == NULL)
return False;
- ZERO_STRUCTP(*param);
+ memset((char *)*param, '\0', sizeof(NT_PRINTER_PARAM));
DEBUGADD(6,("Allocated a new PARAM struct\n"));
}
unistr2_to_ascii((*param)->value, value, sizeof((*param)->value)-1);
(*param)->data_len=len;
- (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
- if((*param)->data == NULL)
- return False;
-
- memcpy((*param)->data, data, len);
+ if (len) {
+ (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
+ if((*param)->data == NULL)
+ return False;
+ memcpy((*param)->data, data, len);
+ }
DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len));
+ dump_data(10, (char *)(*param)->data, (*param)->data_len);
return True;
}
/*******************************************************************
********************************************************************/
+
static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_addform");
/*******************************************************************
********************************************************************/
+
+BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
+ return False;
+ if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
+BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+
BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
{
- uint32 useless_ptr=0;
+ uint32 useless_ptr=1;
prs_debug(ps, depth, desc, "spoolss_io_q_addform");
depth++;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_addform");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
{
- uint32 useless_ptr=0;
+ uint32 useless_ptr=1;
prs_debug(ps, depth, desc, "spoolss_io_q_setform");
depth++;
/*******************************************************************
********************************************************************/
+
BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_setform");
if(!prs_align(ps))
return False;
- if(!prs_uint32("status", ps, depth, &r_u->status))
+ if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
Parse a SPOOL_R_GETJOB structure.
********************************************************************/
+
BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
if (!prs_align(ps))
return False;
- if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
return False;
if (!prs_align(ps))
if (!prs_uint32("needed", ps, depth, &r_u->needed))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
/*******************************************************************
Parse a SPOOL_Q_GETJOB structure.
********************************************************************/
+
BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "");
if(!prs_uint32("level", ps, depth, &q_u->level))
return False;
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
return False;
if(!prs_align(ps))
void free_devmode(DEVICEMODE *devmode)
{
if (devmode!=NULL) {
- safe_free(devmode->private);
- safe_free(devmode);
+ SAFE_FREE(devmode->private);
+ SAFE_FREE(devmode);
}
}
void free_printer_info_1(PRINTER_INFO_1 *printer)
{
- safe_free(printer);
+ SAFE_FREE(printer);
}
void free_printer_info_2(PRINTER_INFO_2 *printer)
if (printer!=NULL) {
free_devmode(printer->devmode);
printer->devmode = NULL;
- if (printer->secdesc != NULL)
- free_sec_desc(&printer->secdesc);
- safe_free(printer);
+ SAFE_FREE(printer);
}
}
void free_printer_info_3(PRINTER_INFO_3 *printer)
{
- if (printer!=NULL) {
- if (printer->secdesc != NULL)
- free_sec_desc(&printer->secdesc);
- safe_free(printer);
- }
+ SAFE_FREE(printer);
}
-void free_spool_printer_info_1(SPOOL_PRINTER_INFO_LEVEL_1 *printer)
+void free_printer_info_4(PRINTER_INFO_4 *printer)
{
- safe_free(printer);
+ SAFE_FREE(printer);
}
-void free_spool_printer_info_2(SPOOL_PRINTER_INFO_LEVEL_2 *printer)
+void free_printer_info_5(PRINTER_INFO_5 *printer)
{
- if (printer!=NULL) {
- if (printer->secdesc != NULL)
- free_sec_desc_buf(&printer->secdesc);
- safe_free(printer);
- }
+ SAFE_FREE(printer);
}
-void free_spool_printer_info_3(SPOOL_PRINTER_INFO_LEVEL_3 *printer)
+void free_job_info_2(JOB_INFO_2 *job)
{
- safe_free(printer);
+ if (job!=NULL)
+ free_devmode(job->devmode);
}
-void free_spool_printer_info_level(SPOOL_PRINTER_INFO_LEVEL *pil)
-{
- if (pil == NULL)
- return;
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
- switch (pil->level) {
- case 1:
- free_spool_printer_info_1(pil->info_1);
- break;
- case 2:
- free_spool_printer_info_2(pil->info_2);
- break;
- case 3:
- free_spool_printer_info_3(pil->info_3);
- break;
- default:
- break;
- }
-}
+BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
+ const fstring string, uint32 printer, uint32 type)
+{
+ if (q_u == NULL)
+ return False;
-static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from)
-{
- PRINTER_INFO_2 *copy = (PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2));
- if (copy != NULL) {
- if (from != NULL)
- memcpy(copy, from, sizeof(*copy));
- else
- ZERO_STRUCTP(copy);
- }
- return copy;
-}
+ init_unistr2(&q_u->string, string, strlen(string)+1);
-void free_print2_array(uint32 num_entries, PRINTER_INFO_2 **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&free_printer_info_2;
- free_void_array(num_entries, (void**)entries, *fn);
-}
+ q_u->printer=printer;
+ q_u->type=type;
-PRINTER_INFO_2 *add_print2_to_array(uint32 *len, PRINTER_INFO_2 ***array,
- const PRINTER_INFO_2 *prt)
-{
- void*(*fn)(const void*) = (void*(*)(const void*))&prt2_dup;
- return (PRINTER_INFO_2*)add_copy_to_array(len,
- (void***)array, (const void*)prt, *fn, True);
-}
+ q_u->unknown0=0x0;
+ q_u->unknown1=0x0;
-static PRINTER_INFO_1 *prt1_dup(const PRINTER_INFO_1* from)
-{
- PRINTER_INFO_1 *copy = (PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1));
- if (copy != NULL) {
- if (from != NULL)
- memcpy(copy, from, sizeof(*copy));
- else
- ZERO_STRUCTP(copy);
- }
- return copy;
+ return True;
}
-void free_print1_array(uint32 num_entries, PRINTER_INFO_1 **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&free;
- free_void_array(num_entries, (void**)entries, *fn);
-}
+/*******************************************************************
+ Parse a SPOOL_Q_REPLYOPENPRINTER structure.
+********************************************************************/
-PRINTER_INFO_1 *add_print1_to_array(uint32 *len, PRINTER_INFO_1 ***array,
- const PRINTER_INFO_1 *prt)
+BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
{
- void*(*fn)(const void*) = (void*(*)(const void*))&prt1_dup;
- return (PRINTER_INFO_1*)add_copy_to_array(len,
- (void***)array, (const void*)prt, *fn, True);
-}
+ prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
+ depth++;
-static JOB_INFO_1 *job1_dup(const JOB_INFO_1* from)
-{
- JOB_INFO_1 *copy = (JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1));
- if (copy != NULL)
- {
- if (from != NULL)
- {
- memcpy(copy, from, sizeof(*copy));
- }
- else
- {
- ZERO_STRUCTP(copy);
- }
- }
- return copy;
-}
+ if(!prs_align(ps))
+ return False;
-void free_job1_array(uint32 num_entries, JOB_INFO_1 **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&free;
- free_void_array(num_entries, (void**)entries, *fn);
-}
+ if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
+ return False;
-JOB_INFO_1 *add_job1_to_array(uint32 *len, JOB_INFO_1 ***array,
- const JOB_INFO_1 *job)
-{
- void*(*fn)(const void*) = (void*(*)(const void*))&job1_dup;
- return (JOB_INFO_1*)add_copy_to_array(len,
- (void***)array, (const void*)job, *fn, True);
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("printer", ps, depth, &q_u->printer))
+ return False;
+ if(!prs_uint32("type", ps, depth, &q_u->type))
+ return False;
+
+ if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
+ return False;
+ if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
+ return False;
+
+ return True;
}
-static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from)
-{
- JOB_INFO_2 *copy = (JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
- if (copy != NULL)
- {
- if (from != NULL)
- {
- memcpy(copy, from, sizeof(*copy));
- }
- else
- {
- ZERO_STRUCTP(copy);
- }
- }
- return copy;
-}
+/*******************************************************************
+ Parse a SPOOL_R_REPLYOPENPRINTER structure.
+********************************************************************/
-void free_job_info_2(JOB_INFO_2 *job)
-{
- if (job!=NULL)
- {
- free_devmode(job->devmode);
- free(job);
- }
-}
+BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
+ depth++;
-void free_job2_array(uint32 num_entries, JOB_INFO_2 **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&free_job_info_2;
- free_void_array(num_entries, (void**)entries, *fn);
+ if (!prs_align(ps))
+ return False;
+
+ if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
+ return False;
+
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
}
-JOB_INFO_2 *add_job2_to_array(uint32 *len, JOB_INFO_2 ***array,
- const JOB_INFO_2 *job)
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd,
+ uint32 condition, uint32 change_id)
{
- void*(*fn)(const void*) = (void*(*)(const void*))&job2_dup;
- return (JOB_INFO_2*)add_copy_to_array(len,
- (void***)array, (const void*)job, *fn, True);
+
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+
+ q_u->condition = condition;
+ q_u->change_id = change_id;
+
+ /* magic values */
+ q_u->unknown1 = 0x1;
+ memset(q_u->unknown2, 0x0, 5);
+ q_u->unknown2[0] = 0x1;
+
+ return True;
}
/*******************************************************************
- Parse a SPOOL_Q_REPLYOPENPRINTER structure.
-********************************************************************/
-BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
+ Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
+********************************************************************/
+BOOL spoolss_io_q_routerreplyprinter (char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter");
depth++;
- if(!prs_align(ps))
+ if (!prs_align(ps))
return False;
- if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
+ if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
return False;
- if(!prs_align(ps))
+ if (!prs_uint32("condition", ps, depth, &q_u->condition))
return False;
- if(!prs_uint32("printer", ps, depth, &q_u->printer))
+ if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
return False;
- if(!prs_uint32("type", ps, depth, &q_u->type))
+
+ if (!prs_uint32("change_id", ps, depth, &q_u->change_id))
return False;
-
- if(!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+
+ if (!prs_uint8s(False, "private", ps, depth, q_u->unknown2, 5))
return False;
return True;
}
/*******************************************************************
- Parse a SPOOL_R_REPLYOPENPRINTER structure.
-********************************************************************/
-BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
+ Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
+********************************************************************/
+BOOL spoolss_io_r_routerreplyprinter (char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter");
depth++;
if (!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
+{
+ if (q_u == NULL)
return False;
- return True;
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+
+ return True;
}
/*******************************************************************
Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
********************************************************************/
+
BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
/*******************************************************************
Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
********************************************************************/
+
BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
{
prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
return False;
- if (!prs_uint32("status", ps, depth, &r_u->status))
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+#if 0 /* JERRY - not currently used but could be :-) */
+
+/*******************************************************************
+ Deep copy a SPOOL_NOTIFY_INFO_DATA structure
+ ******************************************************************/
+static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
+ SPOOL_NOTIFY_INFO_DATA *src, int n)
+{
+ int i;
+
+ memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
+
+ for (i=0; i<n; i++) {
+ int len;
+ uint16 *s = NULL;
+
+ if (src->size != POINTER)
+ continue;
+ len = src->notify_data.data.length;
+ s = malloc(sizeof(uint16)*len);
+ if (s == NULL) {
+ DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
+ return False;
+ }
+
+ memcpy(s, src->notify_data.data.string, len*2);
+ dst->notify_data.data.string = s;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Deep copy a SPOOL_NOTIFY_INFO structure
+ ******************************************************************/
+static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
+{
+ if (!dst) {
+ DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
+ return False;
+ }
+
+ dst->version = src->version;
+ dst->flags = src->flags;
+ dst->count = src->count;
+
+ if (dst->count)
+ {
+ dst->data = malloc(dst->count * sizeof(SPOOL_NOTIFY_INFO_DATA));
+
+ DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
+ dst->count));
+
+ if (dst->data == NULL) {
+ DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
+ dst->count));
+ return False;
+ }
+
+ return (copy_spool_notify_info_data(dst->data, src->data, src->count));
+ }
+
+ return True;
+}
+#endif /* JERRY */
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
+ uint32 change_low, uint32 change_high,
+ SPOOL_NOTIFY_INFO *info)
+{
+ if (q_u == NULL)
+ return False;
+
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+
+ q_u->change_low=change_low;
+ q_u->change_high=change_high;
+
+ q_u->unknown0=0x0;
+ q_u->unknown1=0x0;
+
+ q_u->info_ptr=0xaddee11e;
+
+ q_u->info.version=2;
+
+ if (info->count) {
+ DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
+ info->count));
+ q_u->info.version = info->version;
+ q_u->info.flags = info->flags;
+ q_u->info.count = info->count;
+ /* pointer field - be careful! */
+ q_u->info.data = info->data;
+ }
+ else {
+ q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
+ q_u->info.count=0;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Parse a SPOOL_Q_REPLY_RRPCN structure.
+********************************************************************/
+
+BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+
+ if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
+ return False;
+
+ if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
+ return False;
+
+ if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
+ return False;
+
+ if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
+ return False;
+
+ if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
+ return False;
+
+ if(q_u->info_ptr!=0)
+ if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Parse a SPOOL_R_REPLY_RRPCN structure.
+********************************************************************/
+
+BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
+ return False;
+
+ if (!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
}
+
+/*******************************************************************
+ * read a structure.
+ * called from spoolss_q_getprinterdataex (srv_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_q_getprinterdataex(char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("size", ps, depth, &q_u->size))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ * called from spoolss_r_getprinterdataex (srv_spoolss.c)
+ ********************************************************************/
+
+BOOL spoolss_io_r_getprinterdataex(char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("type", ps, depth, &r_u->type))
+ return False;
+ if (!prs_uint32("size", ps, depth, &r_u->size))
+ return False;
+
+ if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+ if (!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * read a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_q_setprinterdataex(char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
+ return False;
+ if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("type", ps, depth, &q_u->type))
+ return False;
+
+ if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
+ return False;
+
+ switch (q_u->type)
+ {
+ case 0x1:
+ case 0x3:
+ case 0x4:
+ case 0x7:
+ if (q_u->max_len) {
+ if (UNMARSHALLING(ps))
+ q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
+ if(q_u->data == NULL)
+ return False;
+ if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
+ return False;
+ }
+ if(!prs_align(ps))
+ return False;
+ break;
+ }
+
+ if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_r_setprinterdataex(char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ * read a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_q_enumprinterkey(char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("size", ps, depth, &q_u->size))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_r_enumprinterkey(char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!smb_io_buffer5("", &r_u->keys, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ * read a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_q_enumprinterdataex(char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("size", ps, depth, &q_u->size))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
+ PRINTER_ENUM_VALUES_CTR *ctr, int depth)
+{
+ int i;
+ uint32 valuename_offset,
+ data_offset,
+ current_offset;
+ const uint32 basic_unit = 20; /* size of static portion of enum_values */
+
+ prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
+ depth++;
+
+ if (!prs_uint32("size", ps, depth, &ctr->size))
+ return False;
+
+ /* offset data begins at 20 bytes per structure * size_of_array.
+ Don't forget the uint32 at the beginning */
+
+ current_offset = basic_unit * ctr->size_of_array;
+
+ /* first loop to write basic enum_value information */
+
+ for (i=0; i<ctr->size_of_array; i++)
+ {
+ valuename_offset = current_offset;
+ if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
+ return False;
+
+ if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
+ return False;
+
+ if (!prs_uint32("type", ps, depth, &ctr->values[i].type))
+ return False;
+
+ data_offset = ctr->values[i].value_len + valuename_offset;
+ if (!prs_uint32("data_offset", ps, depth, &data_offset))
+ return False;
+
+ if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
+ return False;
+
+ current_offset = data_offset + ctr->values[i].data_len - basic_unit;
+ }
+
+ /* loop #2 for writing the dynamically size objects
+ while viewing conversations between Win2k -> Win2k,
+ 4-byte alignment does not seem to matter here --jerry */
+
+ for (i=0; i<ctr->size_of_array; i++)
+ {
+
+ if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
+ return False;
+
+ if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
+ return False;
+ }
+
+
+
+ return True;
+}
+
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_r_enumprinterdataex(char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if(!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+
+/*
+ uint32 GetPrintProcessorDirectory(
+ [in] unistr2 *name,
+ [in] unistr2 *environment,
+ [in] uint32 level,
+ [in,out] NEW_BUFFER buffer,
+ [in] uint32 offered,
+ [out] uint32 needed,
+ [out] uint32 returned
+ );
+
+*/
+
+BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, NEW_BUFFER *buffer, uint32 offered)
+{
+ DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
+
+ init_unistr2(&q_u->name, name, strlen(name)+1);
+ init_unistr2(&q_u->environment, environment, strlen(environment)+1);
+
+ q_u->level = level;
+
+ q_u->buffer = buffer;
+ q_u->offered = offered;
+
+ return True;
+}
+
+BOOL spoolss_io_q_getprintprocessordirectory(char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth)
+{
+ uint32 ptr;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr", ps, depth, &ptr))
+ return False;
+
+ if (ptr) {
+ if(!smb_io_unistr2("name", &q_u->name, True, ps, depth))
+ return False;
+ }
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr", ps, depth, &ptr))
+ return False;
+
+ if (ptr) {
+ if(!smb_io_unistr2("environment", &q_u->environment, True,
+ ps, depth))
+ return False;
+ }
+
+ if (!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
+
+ if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("offered", ps, depth, &q_u->offered))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ ********************************************************************/
+
+BOOL spoolss_io_r_getprintprocessordirectory(char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+BOOL smb_io_printprocessordirectory_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth)
+{
+ prs_struct *ps=&buffer->prs;
+
+ prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!smb_io_unistr(desc, &info->name, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle,
+ int level, FORM *form)
+{
+ memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+ q_u->level = level;
+ q_u->level2 = level;
+ memcpy(&q_u->form, form, sizeof(FORM));
+
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
+ int level, char *form_name, FORM *form)
+{
+ memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+ q_u->level = level;
+ q_u->level2 = level;
+ memcpy(&q_u->form, form, sizeof(FORM));
+ init_unistr2(&q_u->name, form_name, strlen(form_name) + 1);
+
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle, char *form)
+{
+ memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+ init_unistr2(&q_u->name, form, strlen(form) + 1);
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
+ char *formname, uint32 level, NEW_BUFFER *buffer,
+ uint32 offered)
+{
+ memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+ q_u->level = level;
+ init_unistr2(&q_u->formname, formname, strlen(formname) + 1);
+ q_u->buffer=buffer;
+ q_u->offered=offered;
+
+ return True;
+}
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
+ uint32 level, NEW_BUFFER *buffer,
+ uint32 offered)
+{
+ memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+ q_u->level = level;
+ q_u->buffer=buffer;
+ q_u->offered=offered;
+
+ return True;
+}