summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-11-17 12:54:02 +0100
committerGünther Deschner <gd@samba.org>2009-11-23 12:19:11 +0100
commitec56895bdec90cc671a0d562749b3caf161dbdf8 (patch)
tree1021dd01905194f38b9c2b38f3b429033d3637a8
parent68cc1166d96ac81abce78a7eb60b7b86d0eb4eda (diff)
downloadsamba-ec56895bdec90cc671a0d562749b3caf161dbdf8.tar.gz
samba-ec56895bdec90cc671a0d562749b3caf161dbdf8.tar.bz2
samba-ec56895bdec90cc671a0d562749b3caf161dbdf8.zip
s3-printing: use spoolss types and structs while getting and deleting drivers.
Guenther
-rw-r--r--source3/include/proto.h15
-rw-r--r--source3/printing/nt_printing.c323
-rw-r--r--source3/registry/reg_backend_printing.c31
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c307
-rw-r--r--source3/smbd/lanman.c61
5 files changed, 362 insertions, 375 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fa994938b8..b708c26100 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4882,13 +4882,16 @@ uint32_t add_a_printer_driver(TALLOC_CTX *mem_ctx,
struct spoolss_AddDriverInfoCtr *r,
char **driver_name,
uint32_t *version);
-WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level,
- const char *drivername, const char *architecture, uint32_t version);
-uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
-bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 );
-bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info );
+WERROR get_a_printer_driver(TALLOC_CTX *mem_ctx,
+ union spoolss_DriverInfo **driver_p, uint32_t level,
+ const char *drivername, const char *architecture,
+ uint32_t version);
+uint32_t free_a_printer_driver(union spoolss_DriverInfo *driver);
+bool printer_driver_in_use(const struct spoolss_DriverInfo3 *info_3);
+bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo3 *info);
WERROR delete_printer_driver(struct pipes_struct *rpc_pipe,
- NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3,
+ const struct spoolss_DriverInfo3 *info_3,
uint32 version, bool delete_files );
WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr);
bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **secdesc_ctr);
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index d2c3449a33..8fa29aa735 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2161,29 +2161,26 @@ static uint32 add_a_printer_driver_6(struct spoolss_AddDriverInfo6 *driver)
/****************************************************************************
****************************************************************************/
-static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, const char *driver, const char *arch)
-{
- NT_PRINTER_DRIVER_INFO_LEVEL_3 info;
-
- ZERO_STRUCT(info);
-
- fstrcpy(info.name, driver);
- fstrcpy(info.defaultdatatype, "RAW");
- fstrcpy(info.driverpath, "");
- fstrcpy(info.datafile, "");
- fstrcpy(info.configfile, "");
- fstrcpy(info.helpfile, "");
-
- if ((info.dependentfiles= SMB_MALLOC_ARRAY(fstring, 2)) == NULL)
+static WERROR get_a_printer_driver_3_default(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo3 *info,
+ const char *driver, const char *arch)
+{
+ info->driver_name = talloc_strdup(mem_ctx, driver);
+ if (!info->driver_name) {
return WERR_NOMEM;
+ }
- memset(info.dependentfiles, '\0', 2*sizeof(fstring));
- fstrcpy(info.dependentfiles[0], "");
+ info->default_datatype = talloc_strdup(mem_ctx, "RAW");
+ if (!info->default_datatype) {
+ return WERR_NOMEM;
+ }
- *info_ptr = (NT_PRINTER_DRIVER_INFO_LEVEL_3 *)memdup(&info, sizeof(info));
- if (!*info_ptr) {
- SAFE_FREE(info.dependentfiles);
+ info->driver_path = talloc_strdup(mem_ctx, "");
+ info->data_file = talloc_strdup(mem_ctx, "");
+ info->config_file = talloc_strdup(mem_ctx, "");
+ info->help_file = talloc_strdup(mem_ctx, "");
+ if (!info->driver_path || !info->data_file || !info->config_file || !info->help_file) {
return WERR_NOMEM;
}
@@ -2192,18 +2189,18 @@ static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **in
/****************************************************************************
****************************************************************************/
-static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
+
+static WERROR get_a_printer_driver_3(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo3 *driver,
const char *drivername, const char *arch,
uint32_t version)
{
- NT_PRINTER_DRIVER_INFO_LEVEL_3 driver;
TDB_DATA dbuf;
const char *architecture;
int len = 0;
int i;
char *key = NULL;
-
- ZERO_STRUCT(driver);
+ fstring name, driverpath, environment, datafile, configfile, helpfile, monitorname, defaultdatatype;
architecture = get_short_archi(arch);
if ( !architecture ) {
@@ -2229,45 +2226,53 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
}
len += tdb_unpack(dbuf.dptr, dbuf.dsize, "dffffffff",
- &driver.cversion,
- driver.name,
- driver.environment,
- driver.driverpath,
- driver.datafile,
- driver.configfile,
- driver.helpfile,
- driver.monitorname,
- driver.defaultdatatype);
+ &driver->version,
+ name,
+ environment,
+ driverpath,
+ datafile,
+ configfile,
+ helpfile,
+ monitorname,
+ defaultdatatype);
+
+ driver->driver_name = talloc_strdup(mem_ctx, name);
+ driver->architecture = talloc_strdup(mem_ctx, environment);
+ driver->driver_path = talloc_strdup(mem_ctx, driverpath);
+ driver->data_file = talloc_strdup(mem_ctx, datafile);
+ driver->config_file = talloc_strdup(mem_ctx, configfile);
+ driver->help_file = talloc_strdup(mem_ctx, helpfile);
+ driver->monitor_name = talloc_strdup(mem_ctx, monitorname);
+ driver->default_datatype = talloc_strdup(mem_ctx, defaultdatatype);
i=0;
+
while (len < dbuf.dsize) {
- driver.dependentfiles = SMB_REALLOC_ARRAY(driver.dependentfiles, fstring, i+2);
- if ( !driver.dependentfiles ) {
+
+ fstring file;
+
+ driver->dependent_files = talloc_realloc(mem_ctx, driver->dependent_files, const char *, i+2);
+ if (!driver->dependent_files ) {
DEBUG(0,("get_a_printer_driver_3: failed to enlarge buffer!\n"));
break;
}
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "f",
- &driver.dependentfiles[i]);
+ &file);
+
+ driver->dependent_files[i] = talloc_strdup(mem_ctx, file);
+
i++;
}
- if ( driver.dependentfiles )
- fstrcpy( driver.dependentfiles[i], "" );
+ if (driver->dependent_files)
+ driver->dependent_files[i] = NULL;
SAFE_FREE(dbuf.dptr);
SAFE_FREE(key);
if (len != dbuf.dsize) {
- SAFE_FREE(driver.dependentfiles);
-
- return get_a_printer_driver_3_default(info_ptr, drivername, arch);
- }
-
- *info_ptr = (NT_PRINTER_DRIVER_INFO_LEVEL_3 *)memdup(&driver, sizeof(driver));
- if (!*info_ptr) {
- SAFE_FREE(driver.dependentfiles);
- return WERR_NOMEM;
+ return get_a_printer_driver_3_default(mem_ctx, driver, drivername, arch);
}
return WERR_OK;
@@ -4658,11 +4663,16 @@ uint32_t add_a_printer_driver(TALLOC_CTX *mem_ctx,
/****************************************************************************
****************************************************************************/
-WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level,
+WERROR get_a_printer_driver(TALLOC_CTX *mem_ctx,
+ union spoolss_DriverInfo **driver_p, uint32_t level,
const char *drivername, const char *architecture,
uint32_t version)
{
WERROR result;
+ union spoolss_DriverInfo *driver;
+
+ driver = talloc_zero(mem_ctx, union spoolss_DriverInfo);
+ W_ERROR_HAVE_NO_MEMORY(driver);
switch (level) {
case 3:
@@ -4670,16 +4680,23 @@ WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level
if ( version == DRIVER_ANY_VERSION ) {
/* look for Win2k first and then for NT4 */
- result = get_a_printer_driver_3(&driver->info_3, drivername,
- architecture, 3);
+ result = get_a_printer_driver_3(driver,
+ &driver->info3,
+ drivername,
+ architecture, 3);
if ( !W_ERROR_IS_OK(result) ) {
- result = get_a_printer_driver_3( &driver->info_3,
- drivername, architecture, 2 );
+ result = get_a_printer_driver_3(driver,
+ &driver->info3,
+ drivername,
+ architecture, 2);
}
} else {
- result = get_a_printer_driver_3(&driver->info_3, drivername,
- architecture, version);
+ result = get_a_printer_driver_3(driver,
+ &driver->info3,
+ drivername,
+ architecture,
+ version);
}
break;
@@ -4688,51 +4705,23 @@ WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level
break;
}
- return result;
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(driver);
+ return result;
+ }
+
+ *driver_p = driver;
+
+ return WERR_OK;
}
/****************************************************************************
****************************************************************************/
-uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
-{
- uint32 result;
- switch (level) {
- case 3:
- {
- NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3;
- if (driver.info_3 != NULL)
- {
- info3=driver.info_3;
- SAFE_FREE(info3->dependentfiles);
- ZERO_STRUCTP(info3);
- SAFE_FREE(info3);
- result=0;
- } else {
- result=4;
- }
- break;
- }
- case 6:
- {
- NT_PRINTER_DRIVER_INFO_LEVEL_6 *info6;
- if (driver.info_6 != NULL) {
- info6=driver.info_6;
- SAFE_FREE(info6->dependentfiles);
- SAFE_FREE(info6->previousnames);
- ZERO_STRUCTP(info6);
- SAFE_FREE(info6);
- result=0;
- } else {
- result=4;
- }
- break;
- }
- default:
- result=1;
- break;
- }
- return result;
+uint32_t free_a_printer_driver(union spoolss_DriverInfo *driver)
+{
+ talloc_free(driver);
+ return 0;
}
@@ -4741,7 +4730,7 @@ uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
to a printer
****************************************************************************/
-bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 )
+bool printer_driver_in_use(const struct spoolss_DriverInfo3 *info_3)
{
int snum;
int n_services = lp_numservices();
@@ -4762,7 +4751,7 @@ bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 )
if ( !W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))) )
continue;
- if ( strequal(info_3->name, printer->info_2->drivername) )
+ if (strequal(info_3->driver_name, printer->info_2->drivername))
in_use = True;
free_a_printer( &printer, 2 );
@@ -4771,28 +4760,28 @@ bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 )
DEBUG(10,("printer_driver_in_use: Completed search through ntprinters.tdb...\n"));
if ( in_use ) {
- NT_PRINTER_DRIVER_INFO_LEVEL d;
+ union spoolss_DriverInfo *d;
WERROR werr;
- DEBUG(5,("printer_driver_in_use: driver \"%s\" is currently in use\n", info_3->name));
+ DEBUG(5,("printer_driver_in_use: driver \"%s\" is currently in use\n", info_3->driver_name));
/* we can still remove the driver if there is one of
"Windows NT x86" version 2 or 3 left */
- if ( !strequal( "Windows NT x86", info_3->environment ) ) {
- werr = get_a_printer_driver( &d, 3, info_3->name, "Windows NT x86", DRIVER_ANY_VERSION );
+ if (!strequal("Windows NT x86", info_3->architecture)) {
+ werr = get_a_printer_driver(talloc_tos(), &d, 3, info_3->driver_name, "Windows NT x86", DRIVER_ANY_VERSION);
}
else {
- switch ( info_3->cversion ) {
+ switch (info_3->version) {
case 2:
- werr = get_a_printer_driver( &d, 3, info_3->name, "Windows NT x86", 3 );
+ werr = get_a_printer_driver(talloc_tos(), &d, 3, info_3->driver_name, "Windows NT x86", 3);
break;
case 3:
- werr = get_a_printer_driver( &d, 3, info_3->name, "Windows NT x86", 2 );
+ werr = get_a_printer_driver(talloc_tos(), &d, 3, info_3->driver_name, "Windows NT x86", 2);
break;
default:
DEBUG(0,("printer_driver_in_use: ERROR! unknown driver version (%d)\n",
- info_3->cversion));
+ info_3->version));
werr = WERR_UNKNOWN_PRINTER_DRIVER;
break;
}
@@ -4803,7 +4792,7 @@ bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 )
if ( W_ERROR_IS_OK(werr) ) {
/* it's ok to remove the driver, we have other architctures left */
in_use = False;
- free_a_printer_driver( d, 3 );
+ free_a_printer_driver(d);
}
}
@@ -4817,7 +4806,7 @@ bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 )
Check to see if a ogiven file is in use by *info
*********************************************************************/
-static bool drv_file_in_use( char* file, NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
+static bool drv_file_in_use(const char *file, const struct spoolss_DriverInfo3 *info)
{
int i = 0;
@@ -4829,25 +4818,25 @@ static bool drv_file_in_use( char* file, NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
return false;
}
- if ( strequal(file, info->driverpath) )
+ if (strequal(file, info->driver_path))
return True;
- if ( strequal(file, info->datafile) )
+ if (strequal(file, info->data_file))
return True;
- if ( strequal(file, info->configfile) )
+ if (strequal(file, info->config_file))
return True;
- if ( strequal(file, info->helpfile) )
+ if (strequal(file, info->help_file))
return True;
/* see of there are any dependent files to examine */
- if ( !info->dependentfiles )
+ if (!info->dependent_files)
return False;
- while ( *info->dependentfiles[i] ) {
- if ( strequal(file, info->dependentfiles[i]) )
+ while (info->dependent_files[i] && *info->dependent_files[i]) {
+ if (strequal(file, info->dependent_files[i]))
return True;
i++;
}
@@ -4861,17 +4850,17 @@ static bool drv_file_in_use( char* file, NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
input parameter from the list
*********************************************************************/
-static void trim_dependent_file( fstring files[], int idx )
+static void trim_dependent_file(TALLOC_CTX *mem_ctx, const char **files, int idx)
{
/* bump everything down a slot */
- while( *files[idx+1] ) {
- fstrcpy( files[idx], files[idx+1] );
+ while (files && files[idx+1]) {
+ files[idx] = talloc_strdup(mem_ctx, files[idx+1]);
idx++;
}
- *files[idx] = '\0';
+ files[idx] = NULL;
return;
}
@@ -4880,8 +4869,9 @@ static void trim_dependent_file( fstring files[], int idx )
Check if any of the files used by src are also used by drv
*********************************************************************/
-static bool trim_overlap_drv_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *src,
- NT_PRINTER_DRIVER_INFO_LEVEL_3 *drv )
+static bool trim_overlap_drv_files(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo3 *src,
+ const struct spoolss_DriverInfo3 *drv)
{
bool in_use = False;
int i = 0;
@@ -4891,40 +4881,44 @@ static bool trim_overlap_drv_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *src,
/* check each file. Remove it from the src structure if it overlaps */
- if ( drv_file_in_use(src->driverpath, drv) ) {
+ if (drv_file_in_use(src->driver_path, drv)) {
in_use = True;
- DEBUG(10,("Removing driverfile [%s] from list\n", src->driverpath));
- fstrcpy( src->driverpath, "" );
+ DEBUG(10,("Removing driverfile [%s] from list\n", src->driver_path));
+ src->driver_path = talloc_strdup(mem_ctx, "");
+ if (!src->driver_path) { return false; }
}
- if ( drv_file_in_use(src->datafile, drv) ) {
+ if (drv_file_in_use(src->data_file, drv)) {
in_use = True;
- DEBUG(10,("Removing datafile [%s] from list\n", src->datafile));
- fstrcpy( src->datafile, "" );
+ DEBUG(10,("Removing datafile [%s] from list\n", src->data_file));
+ src->data_file = talloc_strdup(mem_ctx, "");
+ if (!src->data_file) { return false; }
}
- if ( drv_file_in_use(src->configfile, drv) ) {
+ if (drv_file_in_use(src->config_file, drv)) {
in_use = True;
- DEBUG(10,("Removing configfile [%s] from list\n", src->configfile));
- fstrcpy( src->configfile, "" );
+ DEBUG(10,("Removing configfile [%s] from list\n", src->config_file));
+ src->config_file = talloc_strdup(mem_ctx, "");
+ if (!src->config_file) { return false; }
}
- if ( drv_file_in_use(src->helpfile, drv) ) {
+ if (drv_file_in_use(src->help_file, drv)) {
in_use = True;
- DEBUG(10,("Removing helpfile [%s] from list\n", src->helpfile));
- fstrcpy( src->helpfile, "" );
+ DEBUG(10,("Removing helpfile [%s] from list\n", src->help_file));
+ src->help_file = talloc_strdup(mem_ctx, "");
+ if (!src->help_file) { return false; }
}
/* are there any dependentfiles to examine? */
- if ( !src->dependentfiles )
+ if (!src->dependent_files)
return in_use;
- while ( *src->dependentfiles[i] ) {
- if ( drv_file_in_use(src->dependentfiles[i], drv) ) {
+ while (src->dependent_files[i] && *src->dependent_files[i]) {
+ if (drv_file_in_use(src->dependent_files[i], drv)) {
in_use = True;
- DEBUG(10,("Removing [%s] from dependent file list\n", src->dependentfiles[i]));
- trim_dependent_file( src->dependentfiles, i );
+ DEBUG(10,("Removing [%s] from dependent file list\n", src->dependent_files[i]));
+ trim_dependent_file(mem_ctx, src->dependent_files, i);
} else
i++;
}
@@ -4949,19 +4943,20 @@ static bool trim_overlap_drv_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *src,
match.
****************************************************************************/
-bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
+bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo3 *info)
{
int i;
int ndrivers;
uint32 version;
fstring *list = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
bool in_use = false;
if ( !info )
return False;
- version = info->cversion;
+ version = info->version;
/* loop over all driver versions */
@@ -4970,19 +4965,19 @@ bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
/* get the list of drivers */
list = NULL;
- ndrivers = get_ntdrivers(&list, info->environment, version);
+ ndrivers = get_ntdrivers(&list, info->architecture, version);
DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n",
- ndrivers, info->environment, version));
+ ndrivers, info->architecture, version));
/* check each driver for overlap in files */
for (i=0; i<ndrivers; i++) {
DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
- ZERO_STRUCT(driver);
+ driver = NULL;
- if ( !W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, list[i], info->environment, version)) ) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(talloc_tos(), &driver, 3, list[i], info->architecture, version))) {
SAFE_FREE(list);
return True;
}
@@ -4990,8 +4985,8 @@ bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
/* check if d2 uses any files from d1 */
/* only if this is a different driver than the one being deleted */
- if ( !strequal(info->name, driver.info_3->name) ) {
- if ( trim_overlap_drv_files(info, driver.info_3) ) {
+ if (!strequal(info->driver_name, driver->info3.driver_name)) {
+ if (trim_overlap_drv_files(mem_ctx, info, &driver->info3)) {
/* mz: Do not instantly return -
* we need to ensure this file isn't
* also in use by other drivers. */
@@ -4999,15 +4994,13 @@ bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
}
}
- free_a_printer_driver(driver, 3);
+ free_a_printer_driver(driver);
}
SAFE_FREE(list);
DEBUG(5,("printer_driver_files_in_use: Completed search through ntdrivers.tdb...\n"));
- driver.info_3 = info;
-
return in_use;
}
@@ -5036,7 +5029,7 @@ static NTSTATUS driver_unlink_internals(connection_struct *conn,
****************************************************************************/
static bool delete_driver_files(struct pipes_struct *rpc_pipe,
- NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3)
+ const struct spoolss_DriverInfo3 *info_3)
{
int i = 0;
char *s;
@@ -5051,7 +5044,8 @@ static bool delete_driver_files(struct pipes_struct *rpc_pipe,
if ( !info_3 )
return False;
- DEBUG(6,("delete_driver_files: deleting driver [%s] - version [%d]\n", info_3->name, info_3->cversion));
+ DEBUG(6,("delete_driver_files: deleting driver [%s] - version [%d]\n",
+ info_3->driver_name, info_3->version));
fstrcpy(printdollar, "print$");
@@ -5077,32 +5071,32 @@ static bool delete_driver_files(struct pipes_struct *rpc_pipe,
/* now delete the files; must strip the '\print$' string from
fron of path */
- if ( *info_3->driverpath ) {
- if ( (s = strchr( &info_3->driverpath[1], '\\' )) != NULL ) {
+ if (info_3->driver_path && info_3->driver_path[0]) {
+ if ((s = strchr(&info_3->driver_path[1], '\\')) != NULL) {
file = s;
DEBUG(10,("deleting driverfile [%s]\n", s));
driver_unlink_internals(conn, file);
}
}
- if ( *info_3->configfile ) {
- if ( (s = strchr( &info_3->configfile[1], '\\' )) != NULL ) {
+ if (info_3->config_file && info_3->config_file[0]) {
+ if ((s = strchr(&info_3->config_file[1], '\\')) != NULL) {
file = s;
DEBUG(10,("deleting configfile [%s]\n", s));
driver_unlink_internals(conn, file);
}
}
- if ( *info_3->datafile ) {
- if ( (s = strchr( &info_3->datafile[1], '\\' )) != NULL ) {
+ if (info_3->data_file && info_3->data_file[0]) {
+ if ((s = strchr(&info_3->data_file[1], '\\')) != NULL) {
file = s;
DEBUG(10,("deleting datafile [%s]\n", s));
driver_unlink_internals(conn, file);
}
}
- if ( *info_3->helpfile ) {
- if ( (s = strchr( &info_3->helpfile[1], '\\' )) != NULL ) {
+ if (info_3->help_file && info_3->help_file[0]) {
+ if ((s = strchr( &info_3->help_file[1], '\\')) != NULL) {
file = s;
DEBUG(10,("deleting helpfile [%s]\n", s));
driver_unlink_internals(conn, file);
@@ -5111,13 +5105,13 @@ static bool delete_driver_files(struct pipes_struct *rpc_pipe,
/* check if we are done removing files */
- if ( info_3->dependentfiles ) {
- while ( info_3->dependentfiles[i][0] ) {
+ if (info_3->dependent_files) {
+ while (info_3->dependent_files[i] && info_3->dependent_files[i][0]) {
char *p;
/* bypass the "\print$" portion of the path */
- if ( (p = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) {
+ if ((p = strchr(info_3->dependent_files[i]+1, '\\')) != NULL) {
file = p;
DEBUG(10,("deleting dependent file [%s]\n", file));
driver_unlink_internals(conn, file);
@@ -5144,30 +5138,27 @@ static bool delete_driver_files(struct pipes_struct *rpc_pipe,
***************************************************************************/
WERROR delete_printer_driver(struct pipes_struct *rpc_pipe,
- NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3,
+ const struct spoolss_DriverInfo3 *info_3,
uint32 version, bool delete_files )
{
char *key = NULL;
const char *arch;
TDB_DATA dbuf;
- NT_PRINTER_DRIVER_INFO_LEVEL ctr;
/* delete the tdb data first */
- arch = get_short_archi(info_3->environment);
+ arch = get_short_archi(info_3->architecture);
if (!arch) {
return WERR_UNKNOWN_PRINTER_DRIVER;
}
if (asprintf(&key, "%s%s/%d/%s", DRIVERS_PREFIX,
- arch, version, info_3->name) < 0) {
+ arch, version, info_3->driver_name) < 0) {
return WERR_NOMEM;
}
DEBUG(5,("delete_printer_driver: key = [%s] delete_files = %s\n",
key, delete_files ? "TRUE" : "FALSE" ));
- ctr.info_3 = info_3;
-
/* check if the driver actually exists for this environment */
dbuf = tdb_fetch_bystring( tdb_drivers, key );
diff --git a/source3/registry/reg_backend_printing.c b/source3/registry/reg_backend_printing.c
index 453e2b2d0c..05bb6efb38 100644
--- a/source3/registry/reg_backend_printing.c
+++ b/source3/registry/reg_backend_printing.c
@@ -884,7 +884,8 @@ static int key_driver_fetch_keys( const char *key, struct regsubkey_ctr *subkeys
/**********************************************************************
*********************************************************************/
-static void fill_in_driver_values(NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, struct regval_ctr *values)
+static void fill_in_driver_values(const struct spoolss_DriverInfo3 *info3,
+ struct regval_ctr *values)
{
char *buffer = NULL;
int buffer_size = 0;
@@ -892,32 +893,32 @@ static void fill_in_driver_values(NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, struct
const char *filename;
DATA_BLOB data;
- filename = dos_basename( info3->driverpath );
+ filename = dos_basename(info3->driver_path);
regval_ctr_addvalue_sz(values, "Driver", filename);
- filename = dos_basename( info3->configfile );
+ filename = dos_basename(info3->config_file);
regval_ctr_addvalue_sz(values, "Configuration File", filename);
- filename = dos_basename( info3->datafile );
+ filename = dos_basename(info3->data_file);
regval_ctr_addvalue_sz(values, "Data File", filename);
- filename = dos_basename( info3->helpfile );
+ filename = dos_basename(info3->help_file);
regval_ctr_addvalue_sz(values, "Help File", filename);
- regval_ctr_addvalue_sz(values, "Data Type", info3->defaultdatatype);
+ regval_ctr_addvalue_sz(values, "Data Type", info3->default_datatype);
- regval_ctr_addvalue( values, "Version", REG_DWORD, (char*)&info3->cversion,
- sizeof(info3->cversion) );
+ regval_ctr_addvalue( values, "Version", REG_DWORD, (char*)&info3->version,
+ sizeof(info3->version) );
- if ( info3->dependentfiles ) {
+ if (info3->dependent_files) {
/* place the list of dependent files in a single
character buffer, separating each file name by
a NULL */
- for ( i=0; strcmp(info3->dependentfiles[i], ""); i++ ) {
+ for (i=0; info3->dependent_files[i] && strcmp(info3->dependent_files[i], ""); i++) {
/* strip the path to only the file's base name */
- filename = dos_basename( info3->dependentfiles[i] );
+ filename = dos_basename(info3->dependent_files[i]);
length = strlen(filename);
@@ -959,7 +960,7 @@ static int driver_arch_fetch_values(char *key, struct regval_ctr *values)
fstring arch_environment;
fstring driver;
int version;
- NT_PRINTER_DRIVER_INFO_LEVEL driver_ctr;
+ union spoolss_DriverInfo *driver_ctr;
WERROR w_result;
if (!reg_split_path( key, &base, &subkeypath )) {
@@ -1020,14 +1021,14 @@ static int driver_arch_fetch_values(char *key, struct regval_ctr *values)
fstrcpy( driver, base );
- w_result = get_a_printer_driver( &driver_ctr, 3, driver, arch_environment, version );
+ w_result = get_a_printer_driver(talloc_tos(), &driver_ctr, 3, driver, arch_environment, version);
if ( !W_ERROR_IS_OK(w_result) )
return -1;
- fill_in_driver_values( driver_ctr.info_3, values );
+ fill_in_driver_values(&driver_ctr->info3, values);
- free_a_printer_driver( driver_ctr, 3 );
+ free_a_printer_driver(driver_ctr);
/* END PRINTER DRIVER NAME BLOCK */
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index d272a675e6..4f3bf73077 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1918,8 +1918,9 @@ static int get_version_id(const char *arch)
WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
struct spoolss_DeletePrinterDriver *r)
{
- NT_PRINTER_DRIVER_INFO_LEVEL info;
- NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
+
+ union spoolss_DriverInfo *info = NULL;
+ union spoolss_DriverInfo *info_win2k = NULL;
int version;
WERROR status;
WERROR status_win2k = WERR_ACCESS_DENIED;
@@ -1943,10 +1944,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
if ((version = get_version_id(r->in.architecture)) == -1)
return WERR_INVALID_ENVIRONMENT;
- ZERO_STRUCT(info);
- ZERO_STRUCT(info_win2k);
-
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
r->in.architecture,
version)))
{
@@ -1954,7 +1952,8 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
if ( version == 2 ) {
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3,
+ if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx,
+ &info, 3,
r->in.driver,
r->in.architecture,
version))) {
@@ -1970,14 +1969,15 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
}
- if (printer_driver_in_use(info.info_3)) {
+ if (printer_driver_in_use(&info->info3)) {
status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
if ( version == 2 )
{
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ if (W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx,
+ &info_win2k, 3,
r->in.driver,
r->in.architecture, 3)))
{
@@ -1985,8 +1985,8 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
/* remove the Win2k driver first*/
status_win2k = delete_printer_driver(
- p, info_win2k.info_3, 3, false);
- free_a_printer_driver( info_win2k, 3 );
+ p, &info_win2k->info3, 3, false);
+ free_a_printer_driver(info_win2k);
/* this should not have failed---if it did, report to client */
if ( !W_ERROR_IS_OK(status_win2k) )
@@ -1997,7 +1997,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
}
}
- status = delete_printer_driver(p, info.info_3, version, false);
+ status = delete_printer_driver(p, &info->info3, version, false);
/* if at least one of the deletes succeeded return OK */
@@ -2005,7 +2005,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
status = WERR_OK;
done:
- free_a_printer_driver( info, 3 );
+ free_a_printer_driver(info);
return status;
}
@@ -2017,8 +2017,8 @@ done:
WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
struct spoolss_DeletePrinterDriverEx *r)
{
- NT_PRINTER_DRIVER_INFO_LEVEL info;
- NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
+ union spoolss_DriverInfo *info = NULL;
+ union spoolss_DriverInfo *info_win2k = NULL;
int version;
bool delete_files;
WERROR status;
@@ -2046,10 +2046,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
version = r->in.version;
- ZERO_STRUCT(info);
- ZERO_STRUCT(info_win2k);
-
- status = get_a_printer_driver(&info, 3, r->in.driver,
+ status = get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
r->in.architecture, version);
if ( !W_ERROR_IS_OK(status) )
@@ -2066,7 +2063,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
/* try for Win2k driver if "Windows NT x86" */
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
r->in.architecture,
version))) {
status = WERR_UNKNOWN_PRINTER_DRIVER;
@@ -2074,7 +2071,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
}
}
- if ( printer_driver_in_use(info.info_3) ) {
+ if ( printer_driver_in_use(&info->info3) ) {
status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
@@ -2095,7 +2092,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
/* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
- if ( delete_files && printer_driver_files_in_use(info.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info, &info->info3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
status = WERR_ACCESS_DENIED;
goto done;
@@ -2105,14 +2102,14 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
/* also check for W32X86/3 if necessary; maybe we already have? */
if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ if (W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info_win2k, 3,
r->in.driver,
r->in.architecture, 3)))
{
- if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info, &info_win2k->info3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
- free_a_printer_driver( info_win2k, 3 );
+ free_a_printer_driver(info_win2k);
status = WERR_ACCESS_DENIED;
goto done;
}
@@ -2121,8 +2118,8 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
/* remove the Win2k driver first*/
status_win2k = delete_printer_driver(
- p, info_win2k.info_3, 3, delete_files);
- free_a_printer_driver( info_win2k, 3 );
+ p, &info_win2k->info3, 3, delete_files);
+ free_a_printer_driver(info_win2k);
/* this should not have failed---if it did, report to client */
@@ -2131,12 +2128,12 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
}
}
- status = delete_printer_driver(p, info.info_3, version, delete_files);
+ status = delete_printer_driver(p, &info->info3, version, delete_files);
if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) )
status = WERR_OK;
done:
- free_a_printer_driver( info, 3 );
+ free_a_printer_driver(info);
return status;
}
@@ -4504,16 +4501,20 @@ WERROR _spoolss_GetPrinter(pipes_struct *p,
********************************************************************/
static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
- fstring *fstring_array,
+ const char **string_array,
const char *cservername)
{
int i, num_strings = 0;
const char **array = NULL;
- for (i=0; fstring_array && fstring_array[i][0] != '\0'; i++) {
+ if (!string_array) {
+ return NULL;
+ }
+
+ for (i=0; string_array[i] && string_array[i][0] != '\0'; i++) {
const char *str = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, fstring_array[i]);
+ cservername, string_array[i]);
if (!str) {
TALLOC_FREE(array);
return NULL;
@@ -4540,11 +4541,11 @@ static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info1(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo1 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername,
const char *architecture)
{
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
return WERR_OK;
@@ -4556,38 +4557,38 @@ static WERROR fill_printer_driver_info1(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo2 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->driverpath);
+ cservername, driver->info3.driver_path);
} else {
r->driver_path = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->driver_path);
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->datafile);
+ cservername, driver->info3.data_file);
} else {
r->data_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->data_file);
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->configfile);
+ cservername, driver->info3.config_file);
} else {
r->config_file = talloc_strdup(mem_ctx, "");
}
@@ -4602,57 +4603,57 @@ static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo3 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->driverpath);
+ cservername, driver->info3.driver_path);
} else {
r->driver_path = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->driver_path);
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->datafile);
+ cservername, driver->info3.data_file);
} else {
r->data_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->data_file);
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->configfile);
+ cservername, driver->info3.config_file);
} else {
r->config_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->config_file);
- if (strlen(driver->info_3->helpfile)) {
+ if (strlen(driver->info3.help_file)) {
r->help_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->helpfile);
+ cservername, driver->info3.help_file);
} else {
r->help_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->help_file);
- r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info3.monitor_name);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
- r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info3.default_datatype);
W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->info_3->dependentfiles,
+ driver->info3.dependent_files,
cservername);
return WERR_OK;
}
@@ -4663,58 +4664,58 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo4 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->driverpath);
+ cservername, driver->info3.driver_path);
} else {
r->driver_path = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->driver_path);
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->datafile);
+ cservername, driver->info3.data_file);
} else {
r->data_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->data_file);
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->configfile);
+ cservername, driver->info3.config_file);
} else {
r->config_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->config_file);
- if (strlen(driver->info_3->helpfile)) {
+ if (strlen(driver->info3.help_file)) {
r->help_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->helpfile);
+ cservername, driver->info3.help_file);
} else {
r->help_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->help_file);
r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->info_3->dependentfiles,
+ driver->info3.dependent_files,
cservername);
- r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info3.monitor_name);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
- r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info3.default_datatype);
W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
r->previous_names = string_array_from_driver_info(mem_ctx,
@@ -4730,37 +4731,37 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo5 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->driverpath);
+ cservername, driver->info3.driver_path);
} else {
r->driver_path = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->driver_path);
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->datafile);
+ cservername, driver->info3.data_file);
} else {
r->data_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->data_file);
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->configfile);
+ cservername, driver->info3.config_file);
} else {
r->config_file = talloc_strdup(mem_ctx, "");
}
@@ -4778,57 +4779,57 @@ static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo6 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->driverpath);
+ cservername, driver->info3.driver_path);
} else {
r->driver_path = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->driver_path);
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->datafile);
+ cservername, driver->info3.data_file);
} else {
r->data_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->data_file);
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->configfile);
+ cservername, driver->info3.config_file);
} else {
r->config_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->config_file);
- if (strlen(driver->info_3->helpfile)) {
+ if (strlen(driver->info3.help_file)) {
r->help_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, driver->info_3->helpfile);
+ cservername, driver->info3.help_file);
} else {
r->help_file = talloc_strdup(mem_ctx, "");
}
W_ERROR_HAVE_NO_MEMORY(r->help_file);
- r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info3.monitor_name);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
- r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info3.default_datatype);
W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->info_3->dependentfiles,
+ driver->info3.dependent_files,
cservername);
r->previous_names = string_array_from_driver_info(mem_ctx,
NULL,
@@ -4872,7 +4873,7 @@ static WERROR fill_spoolss_DriverFileInfo(TALLOC_CTX *mem_ctx,
********************************************************************/
static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *cservername,
struct spoolss_DriverFileInfo **info_p,
uint32_t *count_p)
@@ -4885,7 +4886,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
*info_p = NULL;
*count_p = 0;
- if (strlen(driver->info_3->driverpath)) {
+ if (strlen(driver->info3.driver_path)) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
@@ -4893,14 +4894,14 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
result = fill_spoolss_DriverFileInfo(info,
&info[count],
cservername,
- driver->info_3->driverpath,
+ driver->info3.driver_path,
SPOOLSS_DRIVER_FILE_TYPE_RENDERING,
0);
W_ERROR_NOT_OK_RETURN(result);
count++;
}
- if (strlen(driver->info_3->configfile)) {
+ if (strlen(driver->info3.config_file)) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
@@ -4908,14 +4909,14 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
result = fill_spoolss_DriverFileInfo(info,
&info[count],
cservername,
- driver->info_3->configfile,
+ driver->info3.config_file,
SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION,
0);
W_ERROR_NOT_OK_RETURN(result);
count++;
}
- if (strlen(driver->info_3->datafile)) {
+ if (strlen(driver->info3.data_file)) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
@@ -4923,14 +4924,14 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
result = fill_spoolss_DriverFileInfo(info,
&info[count],
cservername,
- driver->info_3->datafile,
+ driver->info3.data_file,
SPOOLSS_DRIVER_FILE_TYPE_DATA,
0);
W_ERROR_NOT_OK_RETURN(result);
count++;
}
- if (strlen(driver->info_3->helpfile)) {
+ if (strlen(driver->info3.help_file)) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
@@ -4938,14 +4939,14 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
result = fill_spoolss_DriverFileInfo(info,
&info[count],
cservername,
- driver->info_3->helpfile,
+ driver->info3.help_file,
SPOOLSS_DRIVER_FILE_TYPE_HELP,
0);
W_ERROR_NOT_OK_RETURN(result);
count++;
}
- for (i=0; driver->info_3->dependentfiles[i][0] != '\0'; i++) {
+ for (i=0; driver->info3.dependent_files[i][0] != '\0'; i++) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
@@ -4953,7 +4954,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
result = fill_spoolss_DriverFileInfo(info,
&info[count],
cservername,
- driver->info_3->dependentfiles[i],
+ driver->info3.dependent_files[i],
SPOOLSS_DRIVER_FILE_TYPE_OTHER,
0);
W_ERROR_NOT_OK_RETURN(result);
@@ -4972,17 +4973,17 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
struct spoolss_DriverInfo101 *r,
- const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const union spoolss_DriverInfo *driver,
const char *servername)
{
const char *cservername = canon_servername(servername);
WERROR result;
- r->version = driver->info_3->cversion;
+ r->version = driver->info3.version;
- r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ r->driver_name = talloc_strdup(mem_ctx, driver->info3.driver_name);
W_ERROR_HAVE_NO_MEMORY(r->driver_name);
- r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ r->architecture = talloc_strdup(mem_ctx, driver->info3.architecture);
W_ERROR_HAVE_NO_MEMORY(r->architecture);
result = spoolss_DriverFileInfo_from_driver(mem_ctx, driver,
@@ -4993,10 +4994,10 @@ static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
return result;
}
- r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info3.monitor_name);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
- r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info3.default_datatype);
W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
r->previous_names = string_array_from_driver_info(mem_ctx,
@@ -5029,21 +5030,20 @@ static WERROR construct_printer_driver_info_1(TALLOC_CTX *mem_ctx,
uint32_t version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
WERROR result;
- ZERO_STRUCT(driver);
-
if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
return WERR_INVALID_PRINTER_NAME;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version))) {
free_a_printer(&printer, 2);
return WERR_UNKNOWN_PRINTER_DRIVER;
}
- result = fill_printer_driver_info1(mem_ctx, r, &driver, servername, architecture);
+ result = fill_printer_driver_info1(mem_ctx, r, driver, servername, architecture);
+ free_a_printer_driver(driver);
free_a_printer(&printer,2);
return result;
@@ -5062,22 +5062,22 @@ static WERROR construct_printer_driver_info_2(TALLOC_CTX *mem_ctx,
uint32_t version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
WERROR result;
ZERO_STRUCT(printer);
- ZERO_STRUCT(driver);
if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
return WERR_INVALID_PRINTER_NAME;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version))) {
free_a_printer(&printer, 2);
return WERR_UNKNOWN_PRINTER_DRIVER;
}
- result = fill_printer_driver_info2(mem_ctx, r, &driver, servername);
+ result = fill_printer_driver_info2(mem_ctx, r, driver, servername);
+ free_a_printer_driver(driver);
free_a_printer(&printer,2);
return result;
@@ -5096,7 +5096,7 @@ static WERROR construct_printer_driver_info_3(TALLOC_CTX *mem_ctx,
uint32_t version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
WERROR status;
ZERO_STRUCT(driver);
@@ -5105,7 +5105,7 @@ static WERROR construct_printer_driver_info_3(TALLOC_CTX *mem_ctx,
if (!W_ERROR_IS_OK(status))
return WERR_INVALID_PRINTER_NAME;
- status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
+ status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_3: status: %s\n", win_errstr(status)));
#if 0 /* JERRY */
@@ -5140,8 +5140,9 @@ static WERROR construct_printer_driver_info_3(TALLOC_CTX *mem_ctx,
#endif
- status = fill_printer_driver_info3(mem_ctx, r, &driver, servername);
+ status = fill_printer_driver_info3(mem_ctx, r, driver, servername);
+ free_a_printer_driver(driver);
free_a_printer(&printer,2);
return status;
@@ -5160,11 +5161,9 @@ static WERROR construct_printer_driver_info_6(TALLOC_CTX *mem_ctx,
uint32_t version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
WERROR status;
- ZERO_STRUCT(driver);
-
status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) );
DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
@@ -5172,7 +5171,7 @@ static WERROR construct_printer_driver_info_6(TALLOC_CTX *mem_ctx,
if (!W_ERROR_IS_OK(status))
return WERR_INVALID_PRINTER_NAME;
- status = get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
+ status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
@@ -5189,7 +5188,7 @@ static WERROR construct_printer_driver_info_6(TALLOC_CTX *mem_ctx,
/* Yes - try again with a WinNT driver. */
version = 2;
- status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
+ status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
if (!W_ERROR_IS_OK(status)) {
free_a_printer(&printer,2);
@@ -5197,10 +5196,10 @@ static WERROR construct_printer_driver_info_6(TALLOC_CTX *mem_ctx,
}
}
- status = fill_printer_driver_info6(mem_ctx, r, &driver, servername);
+ status = fill_printer_driver_info6(mem_ctx, r, driver, servername);
free_a_printer(&printer,2);
- free_a_printer_driver(driver, 3);
+ free_a_printer_driver(driver);
return status;
}
@@ -5218,11 +5217,9 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
uint32_t version)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
WERROR result;
- ZERO_STRUCT(driver);
-
result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
@@ -5232,7 +5229,7 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
return WERR_INVALID_PRINTER_NAME;
}
- result = get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ result = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername,
architecture, version);
DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
@@ -5250,7 +5247,7 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
/* Yes - try again with a WinNT driver. */
version = 2;
- result = get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ result = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername,
architecture, version);
DEBUG(8,("construct_printer_driver_info_6: status: %s\n",
win_errstr(result)));
@@ -5260,10 +5257,10 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
}
}
- result = fill_printer_driver_info101(mem_ctx, r, &driver, servername);
+ result = fill_printer_driver_info101(mem_ctx, r, driver, servername);
free_a_printer(&printer, 2);
- free_a_printer_driver(driver, 3);
+ free_a_printer_driver(driver);
return result;
}
@@ -6559,7 +6556,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
int ndrivers;
uint32_t version;
fstring *list = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
union spoolss_DriverInfo *info = NULL;
uint32_t count = 0;
WERROR result = WERR_OK;
@@ -6593,7 +6590,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
for (i=0; i<ndrivers; i++) {
DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
ZERO_STRUCT(driver);
- result = get_a_printer_driver(&driver, 3, list[i],
+ result = get_a_printer_driver(mem_ctx, &driver, 3, list[i],
architecture, version);
if (!W_ERROR_IS_OK(result)) {
goto out;
@@ -6602,39 +6599,39 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
switch (level) {
case 1:
result = fill_printer_driver_info1(info, &info[count+i].info1,
- &driver, servername,
+ driver, servername,
architecture);
break;
case 2:
result = fill_printer_driver_info2(info, &info[count+i].info2,
- &driver, servername);
+ driver, servername);
break;
case 3:
result = fill_printer_driver_info3(info, &info[count+i].info3,
- &driver, servername);
+ driver, servername);
break;
case 4:
result = fill_printer_driver_info4(info, &info[count+i].info4,
- &driver, servername);
+ driver, servername);
break;
case 5:
result = fill_printer_driver_info5(info, &info[count+i].info5,
- &driver, servername);
+ driver, servername);
break;
case 6:
result = fill_printer_driver_info6(info, &info[count+i].info6,
- &driver, servername);
+ driver, servername);
break;
default:
result = WERR_UNKNOWN_LEVEL;
break;
}
+ free_a_printer_driver(driver);
+
if (!W_ERROR_IS_OK(result)) {
- free_a_printer_driver(driver, 3);
goto out;
}
- free_a_printer_driver(driver, 3);
}
count += ndrivers;
@@ -7604,9 +7601,9 @@ WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
*/
case 2:
{
- NT_PRINTER_DRIVER_INFO_LEVEL driver1;
+ union spoolss_DriverInfo *driver1;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver1, 3, driver_name, "Windows NT x86", 3))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &driver1, 3, driver_name, "Windows NT x86", 3))) {
/*
* No 2k/Xp driver found, delete init data (if any) for the new Nt driver.
*/
@@ -7617,7 +7614,7 @@ WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
/*
* a 2k/Xp driver was found, don't delete init data because Nt driver will use it.
*/
- free_a_printer_driver(driver1,3);
+ free_a_printer_driver(driver1);
DEBUG(10,("%s: init data not deleted for Nt driver [%s]\n",
fn, driver_name));
}
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 6fc72c27ea..074f7e2c37 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -646,18 +646,16 @@ static void fill_printq_info_52(connection_struct *conn, int snum,
{
int i;
fstring location;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver = NULL;
NT_PRINTER_INFO_LEVEL *printer = NULL;
- ZERO_STRUCT(driver);
-
if ( !W_ERROR_IS_OK(get_a_printer( NULL, &printer, 2, lp_servicename(snum))) ) {
DEBUG(3,("fill_printq_info_52: Failed to lookup printer [%s]\n",
lp_servicename(snum)));
goto err;
}
- if ( !W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ if (!W_ERROR_IS_OK(get_a_printer_driver(talloc_tos(), &driver, 3, printer->info_2->drivername,
"Windows 4.0", 0)) )
{
DEBUG(3,("fill_printq_info_52: Failed to lookup driver [%s]\n",
@@ -665,38 +663,38 @@ static void fill_printq_info_52(connection_struct *conn, int snum,
goto err;
}
- trim_string(driver.info_3->driverpath, "\\print$\\WIN40\\0\\", 0);
- trim_string(driver.info_3->datafile, "\\print$\\WIN40\\0\\", 0);
- trim_string(driver.info_3->helpfile, "\\print$\\WIN40\\0\\", 0);
+ trim_string((char *)driver->info3.driver_path, "\\print$\\WIN40\\0\\", 0);
+ trim_string((char *)driver->info3.data_file, "\\print$\\WIN40\\0\\", 0);
+ trim_string((char *)driver->info3.help_file, "\\print$\\WIN40\\0\\", 0);
PACKI(desc, "W", 0x0400); /* don't know */
- PACKS(desc, "z", driver.info_3->name); /* long printer name */
- PACKS(desc, "z", driver.info_3->driverpath); /* Driverfile Name */
- PACKS(desc, "z", driver.info_3->datafile); /* Datafile name */
- PACKS(desc, "z", driver.info_3->monitorname); /* language monitor */
+ PACKS(desc, "z", driver->info3.driver_name); /* long printer name */
+ PACKS(desc, "z", driver->info3.driver_path); /* Driverfile Name */
+ PACKS(desc, "z", driver->info3.data_file); /* Datafile name */
+ PACKS(desc, "z", driver->info3.monitor_name); /* language monitor */
fstrcpy(location, "\\\\%L\\print$\\WIN40\\0");
standard_sub_basic( "", "", location, sizeof(location)-1 );
PACKS(desc,"z", location); /* share to retrieve files */
- PACKS(desc,"z", driver.info_3->defaultdatatype); /* default data type */
- PACKS(desc,"z", driver.info_3->helpfile); /* helpfile name */
- PACKS(desc,"z", driver.info_3->driverpath); /* driver name */
+ PACKS(desc,"z", driver->info3.default_datatype); /* default data type */
+ PACKS(desc,"z", driver->info3.help_file); /* helpfile name */
+ PACKS(desc,"z", driver->info3.driver_path); /* driver name */
- DEBUG(3,("Printer Driver Name: %s:\n",driver.info_3->name));
- DEBUG(3,("Driver: %s:\n",driver.info_3->driverpath));
- DEBUG(3,("Data File: %s:\n",driver.info_3->datafile));
- DEBUG(3,("Language Monitor: %s:\n",driver.info_3->monitorname));
+ DEBUG(3,("Printer Driver Name: %s:\n",driver->info3.driver_name));
+ DEBUG(3,("Driver: %s:\n",driver->info3.driver_path));
+ DEBUG(3,("Data File: %s:\n",driver->info3.data_file));
+ DEBUG(3,("Language Monitor: %s:\n",driver->info3.monitor_name));
DEBUG(3,("Driver Location: %s:\n",location));
- DEBUG(3,("Data Type: %s:\n",driver.info_3->defaultdatatype));
- DEBUG(3,("Help File: %s:\n",driver.info_3->helpfile));
+ DEBUG(3,("Data Type: %s:\n",driver->info3.default_datatype));
+ DEBUG(3,("Help File: %s:\n",driver->info3.help_file));
PACKI(desc,"N",count); /* number of files to copy */
- for ( i=0; i<count && driver.info_3->dependentfiles && *driver.info_3->dependentfiles[i]; i++)
+ for ( i=0; i<count && driver->info3.dependent_files && *driver->info3.dependent_files[i]; i++)
{
- trim_string(driver.info_3->dependentfiles[i], "\\print$\\WIN40\\0\\", 0);
- PACKS(desc,"z",driver.info_3->dependentfiles[i]); /* driver files to copy */
- DEBUG(3,("Dependent File: %s:\n",driver.info_3->dependentfiles[i]));
+ trim_string((char *)driver->info3.dependent_files[i], "\\print$\\WIN40\\0\\", 0);
+ PACKS(desc,"z",driver->info3.dependent_files[i]); /* driver files to copy */
+ DEBUG(3,("Dependent File: %s:\n", driver->info3.dependent_files[i]));
}
/* sanity check */
@@ -717,8 +715,7 @@ done:
if ( printer )
free_a_printer( &printer, 2 );
- if ( driver.info_3 )
- free_a_printer_driver( driver, 3 );
+ free_a_printer_driver(driver);
}
@@ -807,7 +804,7 @@ static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
static int get_printerdrivernumber(int snum)
{
int result = 0;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ union spoolss_DriverInfo *driver;
NT_PRINTER_INFO_LEVEL *printer = NULL;
ZERO_STRUCT(driver);
@@ -818,7 +815,7 @@ static int get_printerdrivernumber(int snum)
goto done;
}
- if ( !W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ if (!W_ERROR_IS_OK(get_a_printer_driver(talloc_tos(), &driver, 3, printer->info_2->drivername,
"Windows 4.0", 0)) )
{
DEBUG(3,("get_printerdrivernumber: Failed to lookup driver [%s]\n",
@@ -827,15 +824,13 @@ static int get_printerdrivernumber(int snum)
}
/* count the number of files */
- while ( driver.info_3->dependentfiles && *driver.info_3->dependentfiles[result] )
- result++;
- \
+ while (driver->info3.dependent_files && *driver->info3.dependent_files[result])
+ result++;
done:
if ( printer )
free_a_printer( &printer, 2 );
- if ( driver.info_3 )
- free_a_printer_driver( driver, 3 );
+ free_a_printer_driver(driver);
return result;
}