* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-2000,
* Copyright (C) Jean François Micouleau 1998-2000.
- * Copyright (C) Gerald Carter 2002.
+ * Copyright (C) Gerald Carter 2002-2003.
*
* 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
}
/****************************************************************************
- delete a named form struct
+ Delete a named form struct.
****************************************************************************/
+
BOOL delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR *ret)
{
pstring key;
}
/****************************************************************************
-update a form struct
+ Update a form struct.
****************************************************************************/
+
void update_a_form(nt_forms_struct **list, const FORM *form, int count)
{
int n=0;
unistr2_to_ascii(form_name, &(form->name), sizeof(form_name)-1);
DEBUG(106, ("[%s]\n", form_name));
- for (n=0; n<count; n++)
- {
+ for (n=0; n<count; n++) {
DEBUGADD(106, ("n [%d]:[%s]\n", n, (*list)[n].name));
if (!strncmp((*list)[n].name, form_name, strlen(form_name)))
break;
}
/****************************************************************************
-get the nt drivers list
-
-traverse the database and look-up the matching names
+ Get the nt drivers list.
+ Traverse the database and look-up the matching names.
****************************************************************************/
int get_ntdrivers(fstring **list, const char *architecture, uint32 version)
{
for (kbuf = tdb_firstkey(tdb_drivers);
kbuf.dptr;
newkey = tdb_nextkey(tdb_drivers, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
- if (strncmp(kbuf.dptr, key, strlen(key)) != 0) continue;
+
+ if (strncmp(kbuf.dptr, key, strlen(key)) != 0)
+ continue;
if((fl = Realloc(*list, sizeof(fstring)*(total+1))) == NULL) {
DEBUG(0,("get_ntdrivers: failed to enlarge list!\n"));
}
/****************************************************************************
-function to do the mapping between the long architecture name and
-the short one.
+ Function to do the mapping between the long architecture name and
+ the short one.
****************************************************************************/
BOOL get_short_archi(char *short_archi, const char *long_archi)
{
missing the version info structure, compare the creation date (on Unix use
the modification date). Otherwise chose the numerically larger version number.
****************************************************************************/
-static int file_version_is_newer(connection_struct *conn, fstring new_file,
- fstring old_file)
+
+static int file_version_is_newer(connection_struct *conn, fstring new_file, fstring old_file)
{
BOOL use_version = True;
pstring filepath;
len += tdb_pack(buf+len, buflen-len, "p", nt_devmode);
- if (!nt_devmode) return len;
+ if (!nt_devmode)
+ return len;
len += tdb_pack(buf+len, buflen-len, "ffwwwwwwwwwwwwwwwwwwddddddddddddddp",
nt_devmode->devicename,
/* loop over all keys */
- for ( i=0; i<data->num_keys; i++ )
- {
+ for ( i=0; i<data->num_keys; i++ ) {
val_ctr = &data->keys[i].values;
num_values = regval_ctr_numvals( val_ctr );
/* loop over all values */
- for ( j=0; j<num_values; j++ )
- {
+ for ( j=0; j<num_values; j++ ) {
/* pathname should be stored as <key>\<value> */
val = regval_ctr_specific_value( val_ctr, j );
}
/* FIXME!!! Reorder so this forward declaration is not necessary --jerry */
-static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **, fstring);
+static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **, const char* sharename);
static void free_nt_printer_info_level_2(NT_PRINTER_INFO_LEVEL_2 **);
/****************************************************************************
****************************************************************************/
{
NT_DEVICEMODE *new_nt_devicemode = NULL;
+ if ( !nt_devicemode )
+ return NULL;
+
if ((new_nt_devicemode = (NT_DEVICEMODE *)memdup(nt_devicemode, sizeof(NT_DEVICEMODE))) == NULL) {
DEBUG(0,("dup_nt_devicemode: malloc fail.\n"));
return NULL;
/* clean up all registry keys */
data = &info->data;
- for ( i=0; i<data->num_keys; i++ )
- {
+ for ( i=0; i<data->num_keys; i++ ) {
SAFE_FREE( data->keys[i].name );
regval_ctr_destroy( &data->keys[i].values );
}
}
/****************************************************************************
- allocate and initialize a new slot in
- ***************************************************************************/
+ Allocate and initialize a new slot.
+***************************************************************************/
static int add_new_printer_key( NT_PRINTER_DATA *data, const char *name )
{
/* loop over all existing keys */
- for ( i=0; i<data->num_keys; i++ )
- {
+ for ( i=0; i<data->num_keys; i++ ) {
if ( strequal(data->keys[i].name, name) ) {
DEBUG(12,("lookup_printerkey: Found [%s]!\n", name));
key_index = i;
if ( !data )
return 0;
- for ( i=0; i<data->num_keys; i++ )
- {
- if ( StrnCaseCmp(data->keys[i].name, key, strlen(key)) == 0 )
- {
+ for ( i=0; i<data->num_keys; i++ ) {
+ if ( StrnCaseCmp(data->keys[i].name, key, strlen(key)) == 0 ) {
/* match sure it is a subkey and not the key itself */
key_len = strlen( key );
/* tag of the end */
if (num_subkeys)
- fstrcpy( subkeys_ptr[num_subkeys], "" );
+ fstrcpy(subkeys_ptr[num_subkeys], "" );
*subkeys = subkeys_ptr;
* @return WERROR indicating status of publishing
***************************************************************************/
-WERROR nt_printer_publish(int snum, int action)
+WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR win_rc;
- win_rc = get_a_printer(&printer, 2, lp_servicename(snum));
+ win_rc = get_a_printer(print_hnd, &printer, 2, lp_servicename(snum));
if (!W_ERROR_IS_OK(win_rc))
return win_rc;
return win_rc;
}
-BOOL is_printer_published(int snum, GUID *guid)
+BOOL is_printer_published(Printer_entry *print_hnd, int snum, GUID *guid)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
REGVAL_CTR *ctr;
int i;
- win_rc = get_a_printer(&printer, 2, lp_servicename(snum));
+ win_rc = get_a_printer(print_hnd, &printer, 2, lp_servicename(snum));
if (!W_ERROR_IS_OK(win_rc))
return False;
}
#else
-WERROR nt_printer_publish(int snum, int action)
+WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
{
return WERR_OK;
}
-BOOL is_printer_published(int snum, GUID *guid)
+BOOL is_printer_published(Printer_entry *print_hnd, int snum, GUID *guid)
{
return False;
}
/* remove all keys */
- if ( !strlen(key) )
- {
- for ( i=0; i<data->num_keys; i++ )
- {
+ if ( !strlen(key) ) {
+ for ( i=0; i<data->num_keys; i++ ) {
DEBUG(8,("delete_all_printer_data: Removed all Printer Data from key [%s]\n",
data->keys[i].name));
/* remove a specific key (and all subkeys) */
- for ( i=0; i<data->num_keys; i++ )
- {
- if ( StrnCaseCmp( data->keys[i].name, key, strlen(key)) == 0 )
- {
+ for ( i=0; i<data->num_keys; i++ ) {
+ if ( StrnCaseCmp( data->keys[i].name, key, strlen(key)) == 0 ) {
DEBUG(8,("delete_all_printer_data: Removed all Printer Data from key [%s]\n",
data->keys[i].name));
/* sanity check to see if anything is left */
- if ( !data->num_keys )
- {
+ if ( !data->num_keys ) {
DEBUG(8,("delete_all_printer_data: No keys left for printer [%s]\n", p2->printername ));
SAFE_FREE( data->keys );
/* loop and unpack the rest of the registry values */
- while ( True )
- {
+ while ( True ) {
/* check to see if there are any more registry values */
regval_ctr_addvalue( &printer_data->keys[key_index].values, valuename, type, data_p, size );
- SAFE_FREE(data_p); /* 'B' option to tdb_unpack does a malloc() */
+ SAFE_FREE(data_p); /* 'B' option to tdbpack does a malloc() */
+
DEBUG(8,("specific: [%s:%s], len: %d\n", keyname, valuename, size));
}
}
/****************************************************************************
-get a default printer info 2 struct
+ Get a default printer info 2 struct.
****************************************************************************/
-static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharename)
+static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *sharename)
{
int snum;
NT_PRINTER_INFO_LEVEL_2 info;
/****************************************************************************
****************************************************************************/
-static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharename)
+static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *sharename)
{
pstring key;
NT_PRINTER_INFO_LEVEL_2 info;
}
/****************************************************************************
-debugging function, dump at level 6 the struct in the logs
+ Debugging function, dump at level 6 the struct in the logs.
****************************************************************************/
static uint32 dump_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
DEBUG(106,("Dumping printer at level [%d]\n", level));
- switch (level)
- {
+ switch (level) {
case 2:
{
if (printer.info_2 == NULL)
return result;
}
-/****************************************************************************
- Get the parameters we can substitute in an NT print job.
-****************************************************************************/
-
-void get_printer_subst_params(int snum, fstring *printername, fstring *sharename, fstring *portname)
-{
- NT_PRINTER_INFO_LEVEL *printer = NULL;
-
- **printername = **sharename = **portname = '\0';
-
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
- return;
-
- fstrcpy(*printername, printer->info_2->printername);
- fstrcpy(*sharename, printer->info_2->sharename);
- fstrcpy(*portname, printer->info_2->portname);
-
- free_a_printer(&printer, 2);
-}
-
/****************************************************************************
Update the changeid time.
This is SO NASTY as some drivers need this to change, others need it
dump_a_printer(printer, level);
- switch (level)
- {
+ /*
+ * invalidate cache for all open handles to this printer.
+ * cache for a given handle will be updated on the next
+ * get_a_printer()
+ */
+
+ invalidate_printer_hnd_cache( printer.info_2->sharename );
+
+ switch (level) {
case 2:
{
/*
*/
result=update_a_printer_2(printer.info_2);
+
break;
}
default:
{
BOOL result = False;
- switch (level)
- {
+ switch (level) {
case 2:
result = set_driver_init_2(printer->info_2);
break;
ret = -1;
goto done;
}
- else buf = tb;
+ else
+ buf = tb;
buflen = len;
goto again;
}
dump_a_printer(printer, level);
- switch (level)
- {
+ switch (level) {
case 2:
- {
result = update_driver_init_2(printer.info_2);
break;
- }
default:
result = 1;
break;
*/
DEBUG(8,("save_driver_init_2: Enter...\n"));
- if ( !printer->info_2->devmode && data_len )
- {
+ if ( !printer->info_2->devmode && data_len ) {
/*
* Set devmode on printer info, so entire printer initialization can be
* saved to tdb.
{
WERROR status = WERR_OK;
- switch (level)
- {
+ switch (level) {
case 2:
- {
status = save_driver_init_2( printer, data, data_len );
break;
- }
default:
status = WERR_UNKNOWN_LEVEL;
break;
return status;
}
+/****************************************************************************
+ Deep copy a NT_PRINTER_DATA
+****************************************************************************/
+
+static NTSTATUS copy_printer_data( NT_PRINTER_DATA *dst, NT_PRINTER_DATA *src )
+{
+ int i, j, num_vals, new_key_index;
+ REGVAL_CTR *src_key, *dst_key;
+
+ if ( !dst || !src )
+ return NT_STATUS_NO_MEMORY;
+
+ for ( i=0; i<src->num_keys; i++ ) {
+
+ /* create a new instance of the printerkey in the destination
+ printer_data object */
+
+ new_key_index = add_new_printer_key( dst, src->keys[i].name );
+ dst_key = &dst->keys[new_key_index].values;
+
+ src_key = &src->keys[i].values;
+ num_vals = regval_ctr_numvals( src_key );
+
+ /* dup the printer entire printer key */
+
+ for ( j=0; j<num_vals; j++ ) {
+ regval_ctr_copyvalue( dst_key, regval_ctr_specific_value(src_key, j) );
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+/****************************************************************************
+ Deep copy a NT_PRINTER_INFO_LEVEL_2 structure using malloc()'d memeory
+ Caller must free.
+****************************************************************************/
+
+static NT_PRINTER_INFO_LEVEL_2* dup_printer_2( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL_2 *printer )
+{
+ NT_PRINTER_INFO_LEVEL_2 *copy;
+
+ if ( !printer )
+ return NULL;
+
+ if ( !(copy = (NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2))) )
+ return NULL;
+
+ memcpy( copy, printer, sizeof(NT_PRINTER_INFO_LEVEL_2) );
+
+ /* malloc()'d members copied here */
+
+ copy->devmode = dup_nt_devicemode( printer->devmode );
+
+ ZERO_STRUCT( copy->data );
+ copy_printer_data( ©->data, &printer->data );
+
+ /* this is talloc()'d; very ugly that we have a structure that
+ is half malloc()'d and half talloc()'d but that is the way
+ that the PRINTER_INFO stuff is written right now. --jerry */
+
+ copy->secdesc_buf = dup_sec_desc_buf( ctx, printer->secdesc_buf );
+
+ return copy;
+}
+
/****************************************************************************
Get a NT_PRINTER_INFO_LEVEL struct. It returns malloced memory.
****************************************************************************/
-WERROR get_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, fstring sharename)
+#define ENABLE_PRINT_HND_CACHE 1
+
+WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level,
+ const char *sharename)
{
WERROR result;
NT_PRINTER_INFO_LEVEL *printer = NULL;
DEBUG(10,("get_a_printer: [%s] level %u\n", sharename, (unsigned int)level));
- switch (level)
- {
+ switch (level) {
case 2:
- {
if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) {
DEBUG(0,("get_a_printer: malloc fail.\n"));
return WERR_NOMEM;
}
ZERO_STRUCTP(printer);
+
+ /*
+ * check for cache first. A Printer handle cannot changed
+ * to another printer object so we only check that the printer
+ * is actually for a printer and that the printer_info pointer
+ * is valid
+ */
+#ifdef ENABLE_PRINT_HND_CACHE /* JERRY */
+ if ( print_hnd
+ && (print_hnd->printer_type==PRINTER_HANDLE_IS_PRINTER)
+ && print_hnd->printer_info )
+ {
+ if ( !(printer->info_2 = dup_printer_2(print_hnd->ctx, print_hnd->printer_info->info_2)) ) {
+ DEBUG(0,("get_a_printer: unable to copy cached printer info!\n"));
+
+ SAFE_FREE(printer);
+ return WERR_NOMEM;
+ }
+
+ DEBUG(10,("get_a_printer: using cached copy of printer_info_2\n"));
+
+ *pp_printer = printer;
+ result = WERR_OK;
+
+ break;
+ }
+#endif
+
+ /* no cache; look it up on disk */
+
result=get_a_printer_2(&printer->info_2, sharename);
if (W_ERROR_IS_OK(result)) {
dump_a_printer(*printer, level);
+
+#if ENABLE_PRINT_HND_CACHE /* JERRY */
+ /* save a copy in cache */
+ if ( print_hnd && (print_hnd->printer_type==PRINTER_HANDLE_IS_PRINTER)) {
+ if ( !print_hnd->printer_info )
+ print_hnd->printer_info = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL));
+
+ if ( print_hnd->printer_info ) {
+ print_hnd->printer_info->info_2 = dup_printer_2(print_hnd->ctx, printer->info_2);
+
+ /* don't fail the lookup just because the cache update failed */
+ if ( !print_hnd->printer_info->info_2 )
+ DEBUG(0,("get_a_printer: unable to copy new printer info!\n"));
+ }
+
+ }
+#endif
*pp_printer = printer;
- } else {
- SAFE_FREE(printer);
}
+ else
+ SAFE_FREE(printer);
+
+
break;
- }
default:
result=WERR_UNKNOWN_LEVEL;
break;
if (printer == NULL)
return 0;
- switch (level)
- {
+ switch (level) {
case 2:
- {
- if (printer->info_2 != NULL)
- {
+ if (printer->info_2 != NULL) {
free_nt_printer_info_level_2(&printer->info_2);
result=0;
- }
- else
- {
+ } else
result=4;
- }
break;
- }
+
default:
result=1;
break;
DEBUG(104,("adding a printer at level [%d]\n", level));
dump_a_printer_driver(driver, level);
- switch (level)
- {
+ switch (level) {
case 3:
- {
result=add_a_printer_driver_3(driver.info_3);
break;
- }
case 6:
- {
result=add_a_printer_driver_6(driver.info_6);
break;
- }
+
default:
result=1;
break;
}
/****************************************************************************
****************************************************************************/
+
WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level,
fstring drivername, const char *architecture, uint32 version)
{
WERROR result;
- switch (level)
- {
+ switch (level) {
case 3:
/* Sometime we just want any version of the driver */
result = get_a_printer_driver_3( &driver->info_3,
drivername, architecture, 2 );
}
- }
- else {
+ } else {
result = get_a_printer_driver_3(&driver->info_3, drivername,
architecture, version);
}
{
uint32 result;
- switch (level)
- {
+ switch (level) {
case 3:
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3;
ZERO_STRUCTP(info3);
SAFE_FREE(info3);
result=0;
- }
- else
- {
+ } else {
result=4;
}
break;
case 6:
{
NT_PRINTER_DRIVER_INFO_LEVEL_6 *info6;
- if (driver.info_6 != NULL)
- {
+ 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
- {
+ } else {
result=4;
}
break;
/* loop through the printers.tdb and check for the drivername */
- for (snum=0; snum<n_services; snum++)
- {
+ for (snum=0; snum<n_services; snum++) {
if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
continue;
- if ( !W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) )
+ if ( !W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))) )
continue;
if ( !StrCaseCmp(info_3->name, printer->info_2->drivername) ) {
if ( !info->dependentfiles )
return False;
- while ( *info->dependentfiles[i] )
- {
+ while ( *info->dependentfiles[i] ) {
if ( strequal(file, info->dependentfiles[i]) )
return True;
-
i++;
}
/* bump everything down a slot */
- while( *files[idx+1] )
- {
+ while( *files[idx+1] ) {
fstrcpy( files[idx], files[idx+1] );
idx++;
}
if ( !src->dependentfiles )
return in_use;
- while ( *src->dependentfiles[i] )
- {
+ while ( *src->dependentfiles[i] ) {
if ( drv_file_in_use(src->dependentfiles[i], drv) ) {
in_use = True;
DEBUG(10,("Removing [%s] from dependent file list\n", src->dependentfiles[i]));
trim_dependent_file( src->dependentfiles, i );
- }
- else
+ } else
i++;
}
/* check each driver for overlap in files */
- for (i=0; i<ndrivers; i++)
- {
+ for (i=0; i<ndrivers; i++) {
DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
ZERO_STRUCT(driver);
- 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(&driver, 3, list[i], info->environment, version)) ) {
SAFE_FREE(list);
return True;
}
/* 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 ( !strequal(info->name, driver.info_3->name) ) {
if ( trim_overlap_drv_files(info, driver.info_3) ) {
free_a_printer_driver(driver, 3);
SAFE_FREE( list );
/* check if we are done removing files */
- if ( info_3->dependentfiles )
- {
+ if ( info_3->dependentfiles ) {
while ( *info_3->dependentfiles[i] ) {
char *file;
/* bypass the "\print$" portion of the path */
- if ( (file = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL )
- {
+ if ( (file = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) {
DEBUG(10,("deleting dependent file [%s]\n", file));
unlink_internals(conn, 0, file );
}
fstring key;
char *temp;
- if (strlen(printername) > 2 && (temp = strchr(printername + 2, '\\')))
+ if (strlen(printername) > 2 && (temp = strchr(printername + 2, '\\'))) {
printername = temp + 1;
+ }
/* Fetch security descriptor from tdb */
struct tm *t;
uint32 mins;
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))))
return False;
if (printer->info_2->starttime == 0 && printer->info_2->untiltime == 0)
* Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
* Copyright (C) Jean François Micouleau 1998-2000,
* Copyright (C) Jeremy Allison 2001-2002,
- * Copyright (C) Gerald Carter 2000-2002,
+ * Copyright (C) Gerald Carter 2000-2003,
* Copyright (C) Tim Potter 2001-2002.
*
* This program is free software; you can redistribute it and/or modify
#define MAGIC_DISPLAY_FREQUENCY 0xfade2bad
#define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_"
-#define PRINTER_HANDLE_IS_PRINTER 0
-#define PRINTER_HANDLE_IS_PRINTSERVER 1
+
/* Table to map the driver version */
/* to OS */
int version;
};
-
-/* structure to store the printer handles */
-/* and a reference to what it's pointing to */
-/* and the notify info asked about */
-/* that's the central struct */
-typedef struct _Printer{
- struct _Printer *prev, *next;
- BOOL document_started;
- BOOL page_started;
- uint32 jobid; /* jobid in printing backend */
- BOOL printer_type;
- union {
- fstring handlename;
- fstring printerservername;
- } dev;
- uint32 type;
- uint32 access_granted;
- struct {
- uint32 flags;
- uint32 options;
- fstring localmachine;
- uint32 printerlocal;
- SPOOL_NOTIFY_OPTION *option;
- POLICY_HND client_hnd;
- BOOL client_connected;
- uint32 change;
- /* are we in a FindNextPrinterChangeNotify() call? */
- BOOL fnpcn;
- } notify;
- struct {
- fstring machine;
- fstring user;
- } client;
-
- /* devmode sent in the OpenPrinter() call */
- NT_DEVICEMODE *nt_devmode;
-
-
-} Printer_entry;
-
static Printer_entry *printers_list;
typedef struct _counter_printer_0 {
Printer->notify.client_connected=False;
free_nt_devicemode( &Printer->nt_devmode );
+ free_a_printer( &Printer->printer_info, 2 );
+
+ talloc_destroy( Printer->ctx );
/* Remove from the internal list. */
DLIST_REMOVE(printers_list, Printer);
return find_printer;
}
+/****************************************************************************
+ find printer index by handle
+****************************************************************************/
+
+void invalidate_printer_hnd_cache( char *printername )
+{
+ Printer_entry *p;
+
+ DEBUG(10,("invalidate_printer_hnd_cache: printer [%s]\n", printername));
+
+ for ( p=printers_list; p; p=p->next )
+ {
+ if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER
+ && StrCaseCmp(p->dev.handlename, printername)==0)
+ {
+ DEBUG(10,("invalidating printer_info cache for handl:\n"));
+ free_a_printer( &p->printer_info, 2 );
+ p->printer_info = NULL;
+ }
+ }
+
+ return;
+}
/****************************************************************************
Close printer index by handle.
****************************************************************************/
ZERO_STRUCTP(new_printer);
+ if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) {
+ DEBUG(0,("open_printer_hnd: talloc_init() failed!\n"));
+ return False;
+ }
+
new_printer->notify.option=NULL;
/* Add to the internal list. */
/* add a new group? */
- if ( i == ctr->num_groups )
- {
+ if ( i == ctr->num_groups ) {
ctr->num_groups++;
if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) {
/* loop over all printers */
- for (p = printers_list; p; p = p->next)
- {
+ for (p = printers_list; p; p = p->next) {
SPOOL_NOTIFY_INFO_DATA *data;
uint32 data_len = 0;
uint32 id;
/* build the array of change notifications */
- for ( i=0; i<msg_group->num_msgs; i++ )
- {
+ for ( i=0; i<msg_group->num_msgs; i++ ) {
SPOOLSS_NOTIFY_MSG *msg = &messages[i];
/* Are we monitoring this event? */
/* Convert unix jobid to smb jobid */
- if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID)
- {
+ if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) {
id = sysjob_to_jobid(msg->id);
if (id == -1) {
WERROR result;
NT_PRINTER_INFO_LEVEL *printer = NULL;
- result = get_a_printer(&printer, 2, lp_servicename(snum));
+ result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(result))
continue;
WERROR result;
NT_PRINTER_INFO_LEVEL *printer = NULL;
- result = get_a_printer( &printer, 2, lp_servicename(snum) );
+ result = get_a_printer( NULL, &printer, 2, lp_const_servicename(snum) );
if ( !W_ERROR_IS_OK(result) )
continue;
static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value )
{
- delete_printer_data( printer->info_2, key, value );
-
- return mod_a_printer(*printer, 2);
+ return delete_printer_data( printer->info_2, key, value );
}
/****************************************************************************
{
delete_printer_data( printer->info_2, key, value );
- add_printer_data( printer->info_2, key, value, type, data, real_len );
-
- return mod_a_printer(*printer, 2);
+ return add_printer_data( printer->info_2, key, value, type, data, real_len );
}
/********************************************************************
goto done;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_servicename(snum));
if ( !W_ERROR_IS_OK(status) )
goto done;
*
********************************************************************/
-static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int
+static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int
snum, SPOOL_NOTIFY_OPTION_TYPE
*option_type, uint32 id,
TALLOC_CTX *mem_ctx)
(option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"),
option_type->count, lp_servicename(snum)));
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum))))
return False;
- for(field_num=0; field_num<option_type->count; field_num++)
- {
+ for(field_num=0; field_num<option_type->count; field_num++) {
field = option_type->fields[field_num];
DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field));
if (!search_notify(type, field, &j) )
continue;
- if((tid=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL)
- {
+ if((tid=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n"));
return False;
- }
- else
+ } else
info->data = tid;
current_data = &info->data[info->count];
for (snum=0; snum<n_services; snum++)
{
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
- construct_notify_printer_info ( info, snum, option_type, snum, mem_ctx );
+ construct_notify_printer_info ( Printer, info, snum, option_type, snum, mem_ctx );
}
}
switch ( option_type->type ) {
case PRINTER_NOTIFY_TYPE:
- if(construct_notify_printer_info(info, snum,
+ if(construct_notify_printer_info(Printer, info, snum,
option_type, id,
mem_ctx))
id--;
count = print_queue_status(snum, &queue, &status);
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2,
- lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum))))
goto done;
for (j=0; j<count; j++) {
* fill a printer_info_0 struct
********************************************************************/
-static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
+static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum)
{
pstring chaine;
int count;
time_t setuptime;
print_status_struct status;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
count = print_queue_length(snum, &status);
* construct_printer_info_1
* fill a printer_info_1 struct
********************************************************************/
-static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum)
+static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum)
{
pstring chaine;
pstring chaine2;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
printer->flags=flags;
DEBUGADD(8,("getting printer characteristics\n"));
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
return NULL;
if ( !printer->info_2->devmode ) {
* fill a printer_info_2 struct
********************************************************************/
-static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum)
+static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum)
{
int count;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
print_status_struct status;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
count = print_queue_length(snum, &status);
* fill a printer_info_3 struct
********************************************************************/
-static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum)
+static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
PRINTER_INFO_3 *printer = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
*pp_printer = NULL;
* fill a printer_info_4 struct
********************************************************************/
-static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum)
+static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
* fill a printer_info_5 struct
********************************************************************/
-static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum)
+static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername);
* fill a printer_info_7 struct
********************************************************************/
-static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum)
+static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum)
{
char *guid_str = NULL;
GUID guid;
- if (is_printer_published(snum, &guid)) {
+ if (is_printer_published(print_hnd, snum, &guid)) {
asprintf(&guid_str, "{%s}", uuid_string_static(guid));
strupper(guid_str);
init_unistr(&printer->guid, guid_str);
if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
- if (construct_printer_info_1(flags, ¤t_prt, snum)) {
+ if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) {
if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
SAFE_FREE(printers);
if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
- if (construct_printer_info_2(¤t_prt, snum)) {
+ if (construct_printer_info_2(NULL, ¤t_prt, snum)) {
if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) {
DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
SAFE_FREE(printers);
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_0 *printer=NULL;
if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL)
return WERR_NOMEM;
- construct_printer_info_0(printer, snum);
+ construct_printer_info_0(print_hnd, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_0(printer);
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_1 *printer=NULL;
if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL)
return WERR_NOMEM;
- construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum);
+ construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_1(printer);
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_2 *printer=NULL;
if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL)
return WERR_NOMEM;
- construct_printer_info_2(printer, snum);
+ construct_printer_info_2(print_hnd, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_2(printer);
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_3 *printer=NULL;
- if (!construct_printer_info_3(&printer, snum))
+ if (!construct_printer_info_3(print_hnd, &printer, snum))
return WERR_NOMEM;
/* check the required size. */
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_4 *printer=NULL;
if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_4(printer, snum))
+ if (!construct_printer_info_4(print_hnd, printer, snum))
return WERR_NOMEM;
/* check the required size. */
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_5 *printer=NULL;
if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_5(printer, snum))
+ if (!construct_printer_info_5(print_hnd, printer, snum))
return WERR_NOMEM;
/* check the required size. */
return WERR_OK;
}
-static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_7 *printer=NULL;
if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_7(printer, snum))
+ if (!construct_printer_info_7(print_hnd, printer, snum))
return WERR_NOMEM;
/* check the required size. */
NEW_BUFFER *buffer = NULL;
uint32 offered = q_u->offered;
uint32 *needed = &r_u->needed;
+ Printer_entry *Printer=find_printer_index_by_hnd(p, handle);
int snum;
switch (level) {
case 0:
- return getprinter_level_0(snum, buffer, offered, needed);
+ return getprinter_level_0(Printer, snum, buffer, offered, needed);
case 1:
- return getprinter_level_1(snum, buffer, offered, needed);
+ return getprinter_level_1(Printer, snum, buffer, offered, needed);
case 2:
- return getprinter_level_2(snum, buffer, offered, needed);
+ return getprinter_level_2(Printer, snum, buffer, offered, needed);
case 3:
- return getprinter_level_3(snum, buffer, offered, needed);
+ return getprinter_level_3(Printer, snum, buffer, offered, needed);
case 4:
- return getprinter_level_4(snum, buffer, offered, needed);
+ return getprinter_level_4(Printer, snum, buffer, offered, needed);
case 5:
- return getprinter_level_5(snum, buffer, offered, needed);
+ return getprinter_level_5(Printer, snum, buffer, offered, needed);
case 7:
- return getprinter_level_7(snum, buffer, offered, needed);
+ return getprinter_level_7(Printer, snum, buffer, offered, needed);
}
return WERR_UNKNOWN_LEVEL;
}
ZERO_STRUCT(driver);
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
+ 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)))
ZERO_STRUCT(printer);
ZERO_STRUCT(driver);
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))))
+ 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)))
WERROR status;
ZERO_STRUCT(driver);
- status=get_a_printer(&printer, 2, lp_servicename(snum) );
+ status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) );
DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status)));
if (!W_ERROR_IS_OK(status))
return WERR_INVALID_PRINTER_NAME;
ZERO_STRUCT(driver);
- status=get_a_printer(&printer, 2, lp_servicename(snum) );
+ status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) );
DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status)));
result = WERR_OK;
- if (level!=2) {
- DEBUG(0,("update_printer: Send a mail to samba@samba.org\n"));
- DEBUGADD(0,("with the following message: update_printer: level!=2\n"));
- result = WERR_UNKNOWN_LEVEL;
- goto done;
- }
-
if (!Printer) {
result = WERR_BADFID;
goto done;
goto done;
}
- if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) ||
- (!W_ERROR_IS_OK(get_a_printer(&old_printer, 2, lp_servicename(snum))))) {
+ if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum))) ||
+ (!W_ERROR_IS_OK(get_a_printer(Printer, &old_printer, 2, lp_const_servicename(snum))))) {
result = WERR_BADFID;
goto done;
}
result = WERR_NOMEM;
goto done;
}
-
- /*
- * make sure we actually reload the services after
- * this as smb.conf could have a new section in it
- * .... shouldn't .... but could
- */
- reload_services(False);
}
/* Do sanity check on the requested changes for Samba */
notify_printer_driver(snum, printer->info_2->drivername);
}
- /* Update printer info */
- result = mod_a_printer(*printer, 2);
-
/*
* flag which changes actually occured. This is a small subset of
* all the possible changes. We also have to update things in the
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName",
REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ /* Update printer info */
+ result = mod_a_printer(*printer, 2);
+
done:
free_a_printer(&printer, 2);
free_a_printer(&old_printer, 2);
if (!get_printer_snum(p, handle, &snum))
return WERR_BADFID;
- nt_printer_publish(snum, info7->action);
+ nt_printer_publish(Printer, snum, info7->action);
return WERR_OK;
#else
goto done;
}
- result = get_a_printer(&ntprinter, 2, lp_servicename(snum));
+ result = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum));
if (!W_ERROR_IS_OK(result)) {
*returned = 0;
goto done;
if (!get_printer_snum(p,handle, &snum))
return WERR_BADFID;
- result = get_a_printer(&printer, 2, lp_servicename(snum));
+ result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(result))
return result;
/* out_value should default to "" or else NT4 has
problems unmarshalling the response */
- *out_max_value_len = (in_value_len/sizeof(uint16));
+ *out_max_value_len=(in_value_len/sizeof(uint16));
- if ( (*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL )
+ if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL)
{
result = WERR_NOMEM;
goto done;
*/
/* name */
- *out_max_value_len = ( in_value_len / sizeof(uint16) );
+ *out_max_value_len=(in_value_len/sizeof(uint16));
if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL )
{
result = WERR_NOMEM;
goto done;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
return WERR_ACCESS_DENIED;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
if (!get_printer_snum(p,handle, &snum))
return WERR_BADFID;
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
if (!get_printer_snum(p,handle, &snum))
return WERR_BADFID;
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
if (!get_printer_snum(p,handle, &snum))
return WERR_BADFID;
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
goto done;
}
- ret = get_a_printer(&ntprinter, 2, lp_servicename(snum));
+ ret = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(ret))
goto done;
if ( !get_printer_snum(p,handle, &snum) )
return WERR_BADFID;
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_servicename(snum));
if ( !W_ERROR_IS_OK(status) )
goto done;
return WERR_ACCESS_DENIED;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
status = set_printer_dataex( printer, keyname, valuename, type, data, real_len );
- /* save the OID if one was specified and the previous set call succeeded */
-
- if ( W_ERROR_IS_OK(status) && oid_string )
+ if ( W_ERROR_IS_OK(status) )
{
-
+ /* save the OID if one was specified */
+ if ( oid_string ) {
fstrcat( keyname, "\\" );
fstrcat( keyname, SPOOL_OID_KEY );
REG_SZ, (void*)oid_string, strlen(oid_string)+1 );
}
+ status = mod_a_printer(*printer, 2);
+ }
+
free_a_printer(&printer, 2);
return status;
return WERR_ACCESS_DENIED;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
if ( !get_printer_snum(p,handle, &snum) )
return WERR_BADFID;
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
return WERR_ACCESS_DENIED;
}
- status = get_a_printer(&printer, 2, lp_servicename(snum));
+ status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
return status;
return WERR_BADFID;
ZERO_STRUCT(printer);
- result = get_a_printer(&printer, 2, lp_servicename(snum));
+ result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(result))
return result;