summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-08-18 11:11:48 +0000
committerGerald Carter <jerry@samba.org>2002-08-18 11:11:48 +0000
commit50d224a898fa130460bba4009e18fb54b1390168 (patch)
tree230e89d8edbe5a7397a6f6fd93c3c56537c74bee /source3/printing
parentcaf8f949b6876c6c6ebab135a8403ba550e27d6d (diff)
downloadsamba-50d224a898fa130460bba4009e18fb54b1390168.tar.gz
samba-50d224a898fa130460bba4009e18fb54b1390168.tar.bz2
samba-50d224a898fa130460bba4009e18fb54b1390168.zip
fix to allow EnumPrinterKey() to enumerate multiple levels of subkeys.
Works on the top level. Needs more testing for levels > 1. (This used to be commit 32a7083843f2bf9a3f32027189dbb0ff92927cd4)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 3b85fce020..d51d3bc1bb 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2407,7 +2407,7 @@ int lookup_printerkey( NT_PRINTER_DATA *data, char *name )
for ( i=0; i<data->num_keys; i++ )
{
- if ( strcmp(data->keys[i].name, name) == 0 ) {
+ if ( strequal(data->keys[i].name, name) ) {
DEBUG(12,("lookup_printerkey: Found [%s]!\n", name));
key_index = i;
break;
@@ -2420,6 +2420,66 @@ int lookup_printerkey( NT_PRINTER_DATA *data, char *name )
/****************************************************************************
***************************************************************************/
+
+uint32 get_printer_subkeys( NT_PRINTER_DATA *data, char* key, fstring **subkeys )
+{
+ int i;
+ int key_len;
+ int num_subkeys = 0;
+ char *p;
+ fstring *ptr, *subkeys_ptr = NULL;
+
+ if ( !data )
+ return 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 );
+ if ( strlen(data->keys[i].name) == key_len )
+ continue;
+
+ /* get subkey path */
+
+ p = data->keys[i].name + key_len;
+
+ /* found a match, so allocate space and copy the name */
+
+ if ( !(ptr = Realloc( subkeys_ptr, (num_subkeys+2)*sizeof(fstring))) ) {
+ DEBUG(0,("get_printer_subkeys: Realloc failed for [%d] entries!\n",
+ num_subkeys+1));
+ SAFE_FREE( subkeys );
+ return 0;
+ }
+
+ subkeys_ptr = ptr;
+
+ /* copy the subkey name and trim off any trailing
+ subkeys below it */
+
+ fstrcpy( subkeys_ptr[num_subkeys], p );
+ p = strchr( subkeys_ptr[num_subkeys], '\\' );
+ if ( p )
+ *p = '\0';
+ num_subkeys++;
+ }
+
+ }
+
+ /* tag of the end */
+
+ fstrcpy( subkeys_ptr[num_subkeys], "" );
+
+ *subkeys = subkeys_ptr;
+
+ return num_subkeys;
+}
+
+/****************************************************************************
+ ***************************************************************************/
WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2 )
{
@@ -2465,11 +2525,8 @@ WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value
key_index = lookup_printerkey( &p2->data, key );
if ( key_index == -1 )
- key_index = add_new_printer_key( &p2->data, key );
+ return WERR_OK;
- if ( key_index == -1 )
- return WERR_NOMEM;
-
regval_ctr_delvalue( &p2->data.keys[key_index].values, value );
DEBUG(8,("delete_printer_data: Removed key => [%s], value => [%s]\n",