summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-07-20 04:27:30 +0000
committerGerald Carter <jerry@samba.org>2002-07-20 04:27:30 +0000
commitb516eb62db51fe8a793b73014777ced3038f9aa7 (patch)
tree0e808392b3dd42dcbbc0a5e187f5783cef6301dd /source3/registry
parent39bbeff5b361ffa6a5ff9273cf7fce5f46543703 (diff)
downloadsamba-b516eb62db51fe8a793b73014777ced3038f9aa7.tar.gz
samba-b516eb62db51fe8a793b73014777ced3038f9aa7.tar.bz2
samba-b516eb62db51fe8a793b73014777ced3038f9aa7.zip
enumeration of printers keys ( no data yet ) via the registry
functions now works :-) (This used to be commit c5768538f6cf6ee824bc6e105a3391bbc2ea8e46)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_cachehook.c7
-rw-r--r--source3/registry/reg_db.c8
-rw-r--r--source3/registry/reg_frontend.c10
-rw-r--r--source3/registry/reg_printing.c62
4 files changed, 59 insertions, 28 deletions
diff --git a/source3/registry/reg_cachehook.c b/source3/registry/reg_cachehook.c
index 2139fa7066..547eed392d 100644
--- a/source3/registry/reg_cachehook.c
+++ b/source3/registry/reg_cachehook.c
@@ -70,6 +70,7 @@ REGISTRY_HOOK* reghook_cache_find( char *keyname )
{
char *key;
int len;
+ REGISTRY_HOOK *hook;
if ( !keyname )
return NULL;
@@ -92,7 +93,11 @@ REGISTRY_HOOK* reghook_cache_find( char *keyname )
DEBUG(10,("reghook_cache_find: Searching for keyname [%s]\n", key));
- return sorted_tree_find( cache_tree, key ) ;
+ hook = sorted_tree_find( cache_tree, key ) ;
+
+ SAFE_FREE( key );
+
+ return hook;
}
/**********************************************************************
diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c
index fb6ebdbf7c..714e14e48b 100644
--- a/source3/registry/reg_db.c
+++ b/source3/registry/reg_db.c
@@ -39,8 +39,6 @@ static BOOL init_registry_data( void )
ZERO_STRUCTP( &subkeys );
- regsubkey_ctr_init( &subkeys );
-
/* HKEY_LOCAL_MACHINE */
regsubkey_ctr_init( &subkeys );
@@ -215,6 +213,7 @@ BOOL regdb_store_reg_keys( char *keyname, REGSUBKEY_CTR *ctr )
done:
SAFE_FREE( buffer );
+
return ret;
}
@@ -238,7 +237,7 @@ int regdb_fetch_reg_keys( char* key, REGSUBKEY_CTR *ctr )
pstrcpy( path, key );
/* convert to key format */
- pstring_sub( path, "\\", "/" );
+ pstring_sub( path, "\\", "/" );
dbuf = tdb_fetch_by_string( tdb_reg, path );
@@ -257,7 +256,8 @@ int regdb_fetch_reg_keys( char* key, REGSUBKEY_CTR *ctr )
regsubkey_ctr_addkey( ctr, subkeyname );
}
- SAFE_FREE(dbuf.dptr);
+ SAFE_FREE( dbuf.dptr );
+
return num_items;
}
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index de2b279546..4e3f09fe4e 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -204,15 +204,19 @@ void regsubkey_ctr_init( REGSUBKEY_CTR *ctr )
int regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, char *keyname )
{
uint32 len;
+ char **pp;
if ( keyname )
{
len = strlen( keyname );
if ( ctr->subkeys == 0 )
- ctr->subkeys = talloc( ctr->ctx, 1 );
- else
- talloc_realloc( ctr->ctx, ctr->subkeys, ctr->num_subkeys+1 );
+ ctr->subkeys = talloc( ctr->ctx, sizeof(char*) );
+ else {
+ pp = talloc_realloc( ctr->ctx, ctr->subkeys, sizeof(char*)*(ctr->num_subkeys+1) );
+ if ( pp )
+ ctr->subkeys = pp;
+ }
ctr->subkeys[ctr->num_subkeys] = talloc( ctr->ctx, len+1 );
strncpy( ctr->subkeys[ctr->num_subkeys], keyname, len+1 );
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c
index b2403a3133..99bdb4771f 100644
--- a/source3/registry/reg_printing.c
+++ b/source3/registry/reg_printing.c
@@ -66,7 +66,7 @@ static char* trim_reg_path( char *path )
}
- p = path + strlen(KEY_PRINTING);
+ p = path + strlen( KEY_PRINTING );
if ( *p == '\\' )
p++;
@@ -81,7 +81,7 @@ static char* trim_reg_path( char *path )
handle enumeration of subkeys below KEY_PRINTING\Environments
*********************************************************************/
-static int print_subpath_environments( char *key, REGSUBKEY_CTR *subkeys, int32 idx )
+static int print_subpath_environments( char *key, REGSUBKEY_CTR *subkeys )
{
DEBUG(10,("print_subpath_environments: key=>[%s]\n", key ? key : "NULL" ));
@@ -99,7 +99,7 @@ static int print_subpath_environments( char *key, REGSUBKEY_CTR *subkeys, int32
handle enumeration of subkeys below KEY_PRINTING\Forms
*********************************************************************/
-static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys, int32 idx )
+static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
{
DEBUG(10,("print_subpath_forms: key=>[%s]\n", key ? key : "NULL" ));
@@ -110,7 +110,7 @@ static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys, int32 idx )
handle enumeration of values below KEY_PRINTING\Forms
*********************************************************************/
-static int print_values_forms( char *key, REGVAL_CTR *val, int idx )
+static int print_values_forms( char *key, REGVAL_CTR *val )
{
int num_values = 0;
@@ -148,11 +148,33 @@ static int print_values_forms( char *key, REGVAL_CTR *val, int idx )
handle enumeration of subkeys below KEY_PRINTING\Printers
*********************************************************************/
-static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys, int32 idx )
+static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys )
{
+ int n_services = lp_numservices();
+ int snum;
+ fstring sname;
+
DEBUG(10,("print_subpath_printers: key=>[%s]\n", key ? key : "NULL" ));
- return 0;
+ if ( !key )
+ {
+ /* enumerate all printers */
+
+ for (snum=0; snum<n_services; snum++) {
+ if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
+ continue;
+
+ fstrcpy( sname, lp_servicename(snum) );
+
+ regsubkey_ctr_addkey( subkeys, sname );
+ }
+ }
+ else
+ {
+ /* get information for a specific printer */
+ }
+
+ return regsubkey_ctr_numkeys( subkeys );
}
/**********************************************************************
@@ -161,15 +183,13 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys, int32 idx
valid pointers.
*********************************************************************/
-static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys,
- REGVAL_CTR *val, int32 key_index, int32 val_index )
+static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys, REGVAL_CTR *val )
{
int result = 0;
char *p, *base;
int i;
- DEBUG(10,("handle_printing_subpath: key=>[%s], key_index == [%d], val_index == [%d]\n",
- key, key_index, val_index));
+ DEBUG(10,("handle_printing_subpath: key=>[%s]\n", key ));
/*
* break off the first part of the path
@@ -186,27 +206,31 @@ static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys,
DEBUG(10,("handle_printing_subpath: base=>[%s], i==[%d]\n", base, i));
- if ( (key_index != -1) && !(i < MAX_TOP_LEVEL_KEYS) )
+ if ( !(i < MAX_TOP_LEVEL_KEYS) )
return -1;
-
+
+ /* quick hack for now */
+ if ( !subkeys )
+ return 0;
+
/* Call routine to handle each top level key */
switch ( i )
{
case KEY_INDEX_ENVIR:
if ( subkeys )
- print_subpath_environments( p, subkeys, key_index );
+ print_subpath_environments( p, subkeys );
#if 0 /* JERRY */
if ( val )
- print_subpath_values_environments( p, val, val_index );
+ print_subpath_values_environments( p, val );
#endif
break;
case KEY_INDEX_FORMS:
- result = print_subpath_forms( p, subkeys, key_index );
+ result = print_subpath_forms( p, subkeys );
break;
case KEY_INDEX_PRINTER:
- result = print_subpath_printers( p, subkeys, key_index );
+ result = print_subpath_printers( p, subkeys );
break;
/* default case for top level key that has no handler */
@@ -245,7 +269,7 @@ int printing_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr )
regsubkey_ctr_addkey( subkey_ctr, top_level_keys[num_subkeys] );
}
else
- num_subkeys = handle_printing_subpath( path, subkey_ctr, NULL, -1, -1 );
+ num_subkeys = handle_printing_subpath( path, subkey_ctr, NULL );
SAFE_FREE( path );
@@ -274,11 +298,9 @@ int printing_value_info( char *key, REGVAL_CTR *val )
/* fill in values from the getprinterdata_printer_server() */
if ( top_level )
- {
num_values = 0;
- }
else
- num_values = handle_printing_subpath( path, NULL, val, -1, -1 );
+ num_values = handle_printing_subpath( path, NULL, val );
return num_values;