mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
enumeration of printers keys ( no data yet ) via the registry
functions now works :-)
(This used to be commit c5768538f6
)
This commit is contained in:
parent
39bbeff5b3
commit
b516eb62db
@ -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;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -88,7 +88,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY
|
||||
}
|
||||
else
|
||||
*parent_keyname = '\0';
|
||||
|
||||
|
||||
DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent_keyname, subkeyname));
|
||||
|
||||
@ -102,8 +101,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY
|
||||
|
||||
ZERO_STRUCTP( regkey );
|
||||
|
||||
DLIST_ADD( regkeys_list, regkey );
|
||||
|
||||
/* copy the name */
|
||||
|
||||
pstrcpy( regkey->name, parent_keyname );
|
||||
@ -140,14 +137,17 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY
|
||||
result = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
DEBUG(7,("open_registry_key: exit\n"));
|
||||
|
||||
/* clean up */
|
||||
|
||||
regsubkey_ctr_destroy( &subkeys );
|
||||
|
||||
if ( ! NT_STATUS_IS_OK(result) )
|
||||
SAFE_FREE( regkey );
|
||||
else
|
||||
DLIST_ADD( regkeys_list, regkey );
|
||||
|
||||
|
||||
DEBUG(7,("open_registry_key: exit\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -380,7 +380,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
|
||||
out:
|
||||
init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status);
|
||||
|
||||
DEBUG(5,("reg_open_entry: Exit\n"));
|
||||
DEBUG(5,("_reg_info: Exit\n"));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user