mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r8089: successfully delete printer subkeys via the registry....now for values
(This used to be commit d3427960b0
)
This commit is contained in:
parent
4d13815750
commit
22ea1952c8
@ -2560,6 +2560,38 @@ int add_new_printer_key( NT_PRINTER_DATA *data, const char *name )
|
|||||||
return key_index;
|
return key_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
search for a registry key name in the existing printer data
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
int delete_printer_key( NT_PRINTER_DATA *data, const char *name )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
NT_PRINTER_KEY *printer_key;
|
||||||
|
|
||||||
|
for ( i=0; i<data->num_keys; i++ ) {
|
||||||
|
if ( strequal( data->keys[i].name, name ) ) {
|
||||||
|
|
||||||
|
/* cleanup memory */
|
||||||
|
|
||||||
|
printer_key = &data->keys[i];
|
||||||
|
SAFE_FREE( printer_key->name );
|
||||||
|
regval_ctr_destroy( &printer_key->values );
|
||||||
|
|
||||||
|
/* if not the end of the array, move remaining elements down one slot */
|
||||||
|
|
||||||
|
data->num_keys--;
|
||||||
|
if ( data->num_keys && (i < data->num_keys) )
|
||||||
|
memmove( &data->keys[i], &data->keys[i+1], sizeof(NT_PRINTER_KEY)*(data->num_keys-i) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return data->num_keys;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
search for a registry key name in the existing printer data
|
search for a registry key name in the existing printer data
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
@ -290,8 +290,9 @@ static BOOL key_printers_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
|||||||
char *printers_key;
|
char *printers_key;
|
||||||
char *printername, *printerdatakey;
|
char *printername, *printerdatakey;
|
||||||
NT_PRINTER_INFO_LEVEL *printer = NULL;
|
NT_PRINTER_INFO_LEVEL *printer = NULL;
|
||||||
int i, num_subkeys;
|
int i, num_subkeys, num_existing_keys;
|
||||||
char *subkeyname;
|
char *subkeyname;
|
||||||
|
fstring *existing_subkeys = NULL;
|
||||||
|
|
||||||
printers_key = strip_printers_prefix( key );
|
printers_key = strip_printers_prefix( key );
|
||||||
|
|
||||||
@ -309,12 +310,29 @@ static BOOL key_printers_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
|||||||
printername));
|
printername));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the top level printer keys */
|
||||||
|
|
||||||
|
num_existing_keys = get_printer_subkeys( &printer->info_2->data, "", &existing_subkeys );
|
||||||
|
|
||||||
|
for ( i=0; i<num_existing_keys; i++ ) {
|
||||||
|
|
||||||
|
/* remove the key if it has been deleted */
|
||||||
|
|
||||||
|
if ( !regsubkey_ctr_key_exists( subkeys, existing_subkeys[i] ) ) {
|
||||||
|
DEBUG(5,("key_printers_store_keys: deleting key %s\n",
|
||||||
|
existing_subkeys[i]));
|
||||||
|
delete_printer_key( &printer->info_2->data, existing_subkeys[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
num_subkeys = regsubkey_ctr_numkeys( subkeys );
|
num_subkeys = regsubkey_ctr_numkeys( subkeys );
|
||||||
for ( i=0; i<num_subkeys; i++ ) {
|
for ( i=0; i<num_subkeys; i++ ) {
|
||||||
subkeyname = regsubkey_ctr_specific_key(subkeys, i);
|
subkeyname = regsubkey_ctr_specific_key(subkeys, i);
|
||||||
/* add any missing printer keys */
|
/* add any missing printer keys */
|
||||||
if ( lookup_printerkey(&printer->info_2->data, subkeyname) == -1 ) {
|
if ( lookup_printerkey(&printer->info_2->data, subkeyname) == -1 ) {
|
||||||
|
DEBUG(5,("key_printers_store_keys: adding key %s\n",
|
||||||
|
existing_subkeys[i]));
|
||||||
if ( add_new_printer_key( &printer->info_2->data, subkeyname ) == -1 )
|
if ( add_new_printer_key( &printer->info_2->data, subkeyname ) == -1 )
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user