mirror of
https://github.com/samba-team/samba.git
synced 2025-12-16 00:23:52 +03:00
r8007: * cleanup unused structure from reg_objects.h
* make regdb_store_XXX() and regdb_fetch_XXX() functions non-static * use case sensitive string lookups in reg_dynamic.c since the keys have already been normalized * move to new design for making printing related data available via the winreg pipe (with the intent of allowing writes)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
1e9a8854b1
commit
28c7293ee9
@@ -47,18 +47,5 @@ typedef struct {
|
||||
char **subkeys;
|
||||
} REGSUBKEY_CTR;
|
||||
|
||||
/* represent a registry key with all its subkeys and values */
|
||||
|
||||
struct _regobj_key;
|
||||
|
||||
typedef struct _regobj_key {
|
||||
TALLOC_CTX *ctx;
|
||||
|
||||
char *name;
|
||||
|
||||
REGVAL_CTR values;
|
||||
REGSUBKEY_CTR subkeys;
|
||||
} REGOBJ_KEY;
|
||||
|
||||
#endif /* _REG_OBJECTS_H */
|
||||
|
||||
|
||||
@@ -29,14 +29,6 @@ static TDB_CONTEXT *tdb_reg;
|
||||
|
||||
#define VALUE_PREFIX "SAMBA_REGVAL"
|
||||
|
||||
static BOOL regdb_store_reg_keys( const char *keyname, REGSUBKEY_CTR *subkeys );
|
||||
static BOOL regdb_store_reg_values( const char *keyname, REGVAL_CTR *values);
|
||||
static int regdb_fetch_reg_keys( const char* key, REGSUBKEY_CTR *subkeys );
|
||||
static int regdb_fetch_reg_values( const char* key, REGVAL_CTR *values );
|
||||
|
||||
|
||||
|
||||
|
||||
/* List the deepest path into the registry. All part components will be created.*/
|
||||
|
||||
/* If you want to have a part of the path controlled by the tdb abd part by
|
||||
@@ -129,10 +121,10 @@ static BOOL init_registry_data( void )
|
||||
|
||||
regsubkey_ctr_init( &subkeys );
|
||||
|
||||
regdb_fetch_reg_keys( base, &subkeys );
|
||||
regdb_fetch_keys( base, &subkeys );
|
||||
if ( *subkeyname )
|
||||
regsubkey_ctr_addkey( &subkeys, subkeyname );
|
||||
if ( !regdb_store_reg_keys( base, &subkeys ))
|
||||
if ( !regdb_store_keys( base, &subkeys ))
|
||||
return False;
|
||||
|
||||
regsubkey_ctr_destroy( &subkeys );
|
||||
@@ -144,7 +136,7 @@ static BOOL init_registry_data( void )
|
||||
for ( i=0; builtin_registry_values[i].path != NULL; i++ ) {
|
||||
regval_ctr_init( &values );
|
||||
|
||||
regdb_fetch_reg_values( builtin_registry_values[i].path, &values );
|
||||
regdb_fetch_values( builtin_registry_values[i].path, &values );
|
||||
switch( builtin_registry_values[i].type ) {
|
||||
case REG_DWORD:
|
||||
regval_ctr_addvalue( &values,
|
||||
@@ -167,7 +159,7 @@ static BOOL init_registry_data( void )
|
||||
DEBUG(0,("init_registry_data: invalid value type in builtin_registry_values [%d]\n",
|
||||
builtin_registry_values[i].type));
|
||||
}
|
||||
regdb_store_reg_values( builtin_registry_values[i].path, &values );
|
||||
regdb_store_values( builtin_registry_values[i].path, &values );
|
||||
|
||||
regval_ctr_destroy( &values );
|
||||
}
|
||||
@@ -223,7 +215,7 @@ BOOL init_registry_db( void )
|
||||
fstrings
|
||||
***********************************************************************/
|
||||
|
||||
static BOOL regdb_store_reg_keys_internal( const char *key, REGSUBKEY_CTR *ctr )
|
||||
static BOOL regdb_store_keys_internal( const char *key, REGSUBKEY_CTR *ctr )
|
||||
{
|
||||
TDB_DATA kbuf, dbuf;
|
||||
char *buffer, *tmpbuf;
|
||||
@@ -256,7 +248,7 @@ static BOOL regdb_store_reg_keys_internal( const char *key, REGSUBKEY_CTR *ctr )
|
||||
if ( len > buflen ) {
|
||||
/* allocate some extra space */
|
||||
if ((tmpbuf = SMB_REALLOC( buffer, len*2 )) == NULL) {
|
||||
DEBUG(0,("regdb_store_reg_keys: Failed to realloc memory of size [%d]\n", len*2));
|
||||
DEBUG(0,("regdb_store_keys: Failed to realloc memory of size [%d]\n", len*2));
|
||||
ret = False;
|
||||
goto done;
|
||||
}
|
||||
@@ -289,7 +281,7 @@ done:
|
||||
do not currently exist
|
||||
***********************************************************************/
|
||||
|
||||
static BOOL regdb_store_reg_keys( const char *key, REGSUBKEY_CTR *ctr )
|
||||
BOOL regdb_store_keys( const char *key, REGSUBKEY_CTR *ctr )
|
||||
{
|
||||
int num_subkeys, i;
|
||||
pstring path;
|
||||
@@ -299,12 +291,12 @@ static BOOL regdb_store_reg_keys( const char *key, REGSUBKEY_CTR *ctr )
|
||||
/* fetch a list of the old subkeys so we can determine if any were deleted */
|
||||
|
||||
regsubkey_ctr_init( &old_subkeys );
|
||||
regdb_fetch_reg_keys( key, &old_subkeys );
|
||||
regdb_fetch_keys( key, &old_subkeys );
|
||||
|
||||
/* store the subkey list for the parent */
|
||||
|
||||
if ( !regdb_store_reg_keys_internal( key, ctr ) ) {
|
||||
DEBUG(0,("regdb_store_reg_keys: Failed to store new subkey list for parent [%s}\n", key ));
|
||||
if ( !regdb_store_keys_internal( key, ctr ) ) {
|
||||
DEBUG(0,("regdb_store_keys: Failed to store new subkey list for parent [%s}\n", key ));
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -328,10 +320,10 @@ static BOOL regdb_store_reg_keys( const char *key, REGSUBKEY_CTR *ctr )
|
||||
for ( i=0; i<num_subkeys; i++ ) {
|
||||
pstr_sprintf( path, "%s%c%s", key, '/', regsubkey_ctr_specific_key( ctr, i ) );
|
||||
regsubkey_ctr_init( &subkeys );
|
||||
if ( regdb_fetch_reg_keys( path, &subkeys ) == -1 ) {
|
||||
if ( regdb_fetch_keys( path, &subkeys ) == -1 ) {
|
||||
/* create a record with 0 subkeys */
|
||||
if ( !regdb_store_reg_keys_internal( path, &subkeys ) ) {
|
||||
DEBUG(0,("regdb_store_reg_keys: Failed to store new record for key [%s}\n", path ));
|
||||
if ( !regdb_store_keys_internal( path, &subkeys ) ) {
|
||||
DEBUG(0,("regdb_store_keys: Failed to store new record for key [%s}\n", path ));
|
||||
regsubkey_ctr_destroy( &subkeys );
|
||||
return False;
|
||||
}
|
||||
@@ -348,7 +340,7 @@ static BOOL regdb_store_reg_keys( const char *key, REGSUBKEY_CTR *ctr )
|
||||
released by the caller.
|
||||
***********************************************************************/
|
||||
|
||||
static int regdb_fetch_reg_keys( const char* key, REGSUBKEY_CTR *ctr )
|
||||
int regdb_fetch_keys( const char* key, REGSUBKEY_CTR *ctr )
|
||||
{
|
||||
pstring path;
|
||||
uint32 num_items;
|
||||
@@ -358,7 +350,7 @@ static int regdb_fetch_reg_keys( const char* key, REGSUBKEY_CTR *ctr )
|
||||
int i;
|
||||
fstring subkeyname;
|
||||
|
||||
DEBUG(10,("regdb_fetch_reg_keys: Enter key => [%s]\n", key ? key : "NULL"));
|
||||
DEBUG(10,("regdb_fetch_keys: Enter key => [%s]\n", key ? key : "NULL"));
|
||||
|
||||
pstrcpy( path, key );
|
||||
|
||||
@@ -372,7 +364,7 @@ static int regdb_fetch_reg_keys( const char* key, REGSUBKEY_CTR *ctr )
|
||||
buflen = dbuf.dsize;
|
||||
|
||||
if ( !buf ) {
|
||||
DEBUG(5,("regdb_fetch_reg_keys: tdb lookup failed to locate key [%s]\n", key));
|
||||
DEBUG(5,("regdb_fetch_keys: tdb lookup failed to locate key [%s]\n", key));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -385,7 +377,7 @@ static int regdb_fetch_reg_keys( const char* key, REGSUBKEY_CTR *ctr )
|
||||
|
||||
SAFE_FREE( dbuf.dptr );
|
||||
|
||||
DEBUG(10,("regdb_fetch_reg_keys: Exit [%d] items\n", num_items));
|
||||
DEBUG(10,("regdb_fetch_keys: Exit [%d] items\n", num_items));
|
||||
|
||||
return num_items;
|
||||
}
|
||||
@@ -472,13 +464,13 @@ static int regdb_pack_values(REGVAL_CTR *values, char *buf, int buflen)
|
||||
released by the caller.
|
||||
***********************************************************************/
|
||||
|
||||
static int regdb_fetch_reg_values( const char* key, REGVAL_CTR *values )
|
||||
int regdb_fetch_values( const char* key, REGVAL_CTR *values )
|
||||
{
|
||||
TDB_DATA data;
|
||||
pstring keystr;
|
||||
int len;
|
||||
|
||||
DEBUG(10,("regdb_fetch_reg_values: Looking for value of key [%s] \n", key));
|
||||
DEBUG(10,("regdb_fetch_values: Looking for value of key [%s] \n", key));
|
||||
|
||||
pstr_sprintf( keystr, "%s/%s", VALUE_PREFIX, key );
|
||||
normalize_reg_path( keystr );
|
||||
@@ -502,19 +494,19 @@ static int regdb_fetch_reg_values( const char* key, REGVAL_CTR *values )
|
||||
values in the registry.tdb
|
||||
***********************************************************************/
|
||||
|
||||
static BOOL regdb_store_reg_values( const char *key, REGVAL_CTR *values )
|
||||
BOOL regdb_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
TDB_DATA data;
|
||||
pstring keystr;
|
||||
int len, ret;
|
||||
|
||||
DEBUG(10,("regdb_store_reg_values: Looking for value of key [%s] \n", key));
|
||||
DEBUG(10,("regdb_store_values: Looking for value of key [%s] \n", key));
|
||||
|
||||
ZERO_STRUCT( data );
|
||||
|
||||
len = regdb_pack_values( values, data.dptr, data.dsize );
|
||||
if ( len <= 0 ) {
|
||||
DEBUG(0,("regdb_store_reg_values: unable to pack values. len <= 0\n"));
|
||||
DEBUG(0,("regdb_store_values: unable to pack values. len <= 0\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -541,10 +533,10 @@ static BOOL regdb_store_reg_values( const char *key, REGVAL_CTR *values )
|
||||
*/
|
||||
|
||||
REGISTRY_OPS regdb_ops = {
|
||||
regdb_fetch_reg_keys,
|
||||
regdb_fetch_reg_values,
|
||||
regdb_store_reg_keys,
|
||||
regdb_store_reg_values,
|
||||
regdb_fetch_keys,
|
||||
regdb_fetch_values,
|
||||
regdb_store_keys,
|
||||
regdb_store_values,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ int fetch_dynamic_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
|
||||
normalize_reg_path( path );
|
||||
|
||||
for ( i=0; dynamic_values[i].path; i++ ) {
|
||||
if ( strequal( path, dynamic_values[i].path ) )
|
||||
if ( strcmp( path, dynamic_values[i].path ) == 0 )
|
||||
return dynamic_values[i].fetch_values( val );
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ BOOL check_dynamic_reg_values( REGISTRY_KEY *key )
|
||||
|
||||
for ( i=0; dynamic_values[i].path; i++ ) {
|
||||
/* can't write to dynamic keys */
|
||||
if ( strequal( path, dynamic_values[i].path ) )
|
||||
if ( strcmp( path, dynamic_values[i].path ) == 0 )
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,19 @@
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_RPC_SRV
|
||||
|
||||
struct reg_dyn_tree {
|
||||
/* full key path in normalized form */
|
||||
const char *path;
|
||||
|
||||
/* callbscks for fetch/store operations */
|
||||
int ( *fetch_subkeys) ( const char *path, REGSUBKEY_CTR *subkeys );
|
||||
BOOL (*store_subkeys) ( const char *path, REGSUBKEY_CTR *subkeys );
|
||||
int (*fetch_values) ( const char *path, REGVAL_CTR *values );
|
||||
BOOL (*store_values) ( const char *path, REGVAL_CTR *values );
|
||||
};
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
|
||||
#define MAX_TOP_LEVEL_KEYS 3
|
||||
|
||||
/* some symbolic indexes into the top_level_keys */
|
||||
@@ -100,29 +113,6 @@ static char* trim_reg_path( const char *path )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int fill_ports_values( REGVAL_CTR *values )
|
||||
{
|
||||
int numlines, i;
|
||||
char **lines;
|
||||
UNISTR2 data;
|
||||
WERROR result;
|
||||
|
||||
result = enumports_hook( &numlines, &lines );
|
||||
|
||||
if ( !W_ERROR_IS_OK(result) )
|
||||
return -1;
|
||||
|
||||
init_unistr2( &data, "", UNI_STR_TERMINATE);
|
||||
for ( i=0; i<numlines; i++ )
|
||||
regval_ctr_addvalue( values, lines[i], REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
|
||||
|
||||
return numlines;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
handle enumeration of subkeys below KEY_PRINTING\Environments
|
||||
Environments\$ARCH\Print Processors
|
||||
@@ -456,84 +446,6 @@ static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
handle enumeration of values below KEY_PRINTING\Forms
|
||||
*********************************************************************/
|
||||
|
||||
static int print_subpath_values_forms( char *key, REGVAL_CTR *val )
|
||||
{
|
||||
int num_values = 0;
|
||||
uint32 data[8];
|
||||
int form_index = 1;
|
||||
|
||||
DEBUG(10,("print_values_forms: key=>[%s]\n", key ? key : "NULL" ));
|
||||
|
||||
/* handle ..\Forms\ */
|
||||
|
||||
if ( !key )
|
||||
{
|
||||
nt_forms_struct *forms_list = NULL;
|
||||
nt_forms_struct *form = NULL;
|
||||
int i;
|
||||
|
||||
if ( (num_values = get_ntforms( &forms_list )) == 0 )
|
||||
return 0;
|
||||
|
||||
DEBUG(10,("print_subpath_values_forms: [%d] user defined forms returned\n",
|
||||
num_values));
|
||||
|
||||
/* handle user defined forms */
|
||||
|
||||
for ( i=0; i<num_values; i++ )
|
||||
{
|
||||
form = &forms_list[i];
|
||||
|
||||
data[0] = form->width;
|
||||
data[1] = form->length;
|
||||
data[2] = form->left;
|
||||
data[3] = form->top;
|
||||
data[4] = form->right;
|
||||
data[5] = form->bottom;
|
||||
data[6] = form_index++;
|
||||
data[7] = form->flag;
|
||||
|
||||
regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
|
||||
|
||||
}
|
||||
|
||||
SAFE_FREE( forms_list );
|
||||
forms_list = NULL;
|
||||
|
||||
/* handle built-on forms */
|
||||
|
||||
if ( (num_values = get_builtin_ntforms( &forms_list )) == 0 )
|
||||
return 0;
|
||||
|
||||
DEBUG(10,("print_subpath_values_forms: [%d] built-in forms returned\n",
|
||||
num_values));
|
||||
|
||||
for ( i=0; i<num_values; i++ )
|
||||
{
|
||||
form = &forms_list[i];
|
||||
|
||||
data[0] = form->width;
|
||||
data[1] = form->length;
|
||||
data[2] = form->left;
|
||||
data[3] = form->top;
|
||||
data[4] = form->right;
|
||||
data[5] = form->bottom;
|
||||
data[6] = form_index++;
|
||||
data[7] = form->flag;
|
||||
|
||||
regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
|
||||
}
|
||||
|
||||
SAFE_FREE( forms_list );
|
||||
}
|
||||
|
||||
return num_values;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
handle enumeration of subkeys below KEY_PRINTING\Printers
|
||||
*********************************************************************/
|
||||
@@ -867,65 +779,354 @@ static int printing_subkey_info( const char *key, REGSUBKEY_CTR *subkey_ctr )
|
||||
return num_subkeys;
|
||||
}
|
||||
|
||||
#endif /* UNUSED */
|
||||
|
||||
/**********************************************************************
|
||||
Enumerate registry values given a registry path.
|
||||
Caller is responsible for freeing memory
|
||||
*********************************************************************/
|
||||
|
||||
static int printing_value_info( const char *key, REGVAL_CTR *val )
|
||||
static int key_forms_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_forms_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static int key_forms_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
char *path;
|
||||
int num_values = 0;
|
||||
uint32 data[8];
|
||||
int form_index = 1;
|
||||
int i;
|
||||
|
||||
DEBUG(10,("printing_value_info: key=>[%s]\n", key));
|
||||
DEBUG(10,("print_values_forms: key=>[%s]\n", key ? key : "NULL" ));
|
||||
|
||||
path = trim_reg_path( key );
|
||||
nt_forms_struct *forms_list = NULL;
|
||||
nt_forms_struct *form = NULL;
|
||||
|
||||
if ( path ) {
|
||||
num_values = handle_printing_subpath( path, NULL, val );
|
||||
SAFE_FREE( path );
|
||||
return num_values;
|
||||
if ( (num_values = get_ntforms( &forms_list )) == 0 )
|
||||
return 0;
|
||||
|
||||
DEBUG(10,("hive_forms_fetch_values: [%d] user defined forms returned\n",
|
||||
num_values));
|
||||
|
||||
/* handle user defined forms */
|
||||
|
||||
for ( i=0; i<num_values; i++ ) {
|
||||
form = &forms_list[i];
|
||||
|
||||
data[0] = form->width;
|
||||
data[1] = form->length;
|
||||
data[2] = form->left;
|
||||
data[3] = form->top;
|
||||
data[4] = form->right;
|
||||
data[5] = form->bottom;
|
||||
data[6] = form_index++;
|
||||
data[7] = form->flag;
|
||||
|
||||
regval_ctr_addvalue( values, form->name, REG_BINARY, (char*)data, sizeof(data) );
|
||||
}
|
||||
|
||||
/* top level key */
|
||||
SAFE_FREE( forms_list );
|
||||
forms_list = NULL;
|
||||
|
||||
if ( strequal( key, KEY_PRINTING_PORTS ) )
|
||||
num_values = fill_ports_values( val );
|
||||
/* handle built-on forms */
|
||||
|
||||
return num_values;
|
||||
if ( (num_values = get_builtin_ntforms( &forms_list )) == 0 )
|
||||
return 0;
|
||||
|
||||
DEBUG(10,("print_subpath_values_forms: [%d] built-in forms returned\n",
|
||||
num_values));
|
||||
|
||||
for ( i=0; i<num_values; i++ ) {
|
||||
form = &forms_list[i];
|
||||
|
||||
data[0] = form->width;
|
||||
data[1] = form->length;
|
||||
data[2] = form->left;
|
||||
data[3] = form->top;
|
||||
data[4] = form->right;
|
||||
data[5] = form->bottom;
|
||||
data[6] = form_index++;
|
||||
data[7] = form->flag;
|
||||
|
||||
regval_ctr_addvalue( values, form->name, REG_BINARY, (char*)data, sizeof(data) );
|
||||
}
|
||||
|
||||
SAFE_FREE( forms_list );
|
||||
|
||||
return regval_ctr_numvals( values );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Stub function which always returns failure since we don't want
|
||||
people storing printing information directly via regostry calls
|
||||
(for now at least)
|
||||
*********************************************************************/
|
||||
|
||||
static BOOL printing_store_subkey( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
static BOOL key_forms_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Stub function which always returns failure since we don't want
|
||||
people storing printing information directly via regostry calls
|
||||
(for now at least)
|
||||
*********************************************************************/
|
||||
|
||||
static BOOL printing_store_value( const char *key, REGVAL_CTR *val )
|
||||
static int key_printer_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_printer_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static int key_printer_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_printer_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int key_driver_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_driver_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static int key_driver_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_driver_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int key_print_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_print_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static int key_print_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_print_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int key_ports_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL key_ports_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static int key_ports_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
int numlines, i;
|
||||
char **lines;
|
||||
UNISTR2 data;
|
||||
WERROR result;
|
||||
|
||||
if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &lines )) )
|
||||
return -1;
|
||||
|
||||
init_unistr2( &data, "", UNI_STR_TERMINATE);
|
||||
for ( i=0; i<numlines; i++ )
|
||||
regval_ctr_addvalue( values, lines[i], REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
|
||||
|
||||
return regval_ctr_numvals( values );
|
||||
}
|
||||
|
||||
static BOOL key_ports_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int key_monitor_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return regdb_fetch_keys( key, subkeys );
|
||||
}
|
||||
|
||||
static BOOL key_monitor_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
return regdb_store_keys( key, subkeys );
|
||||
}
|
||||
|
||||
static int key_monitor_fetch_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return regdb_fetch_values( key, values );
|
||||
}
|
||||
|
||||
static BOOL key_monitor_store_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
return regdb_store_values( key, values );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Structure to hold dispatch table of ops for various printer keys.
|
||||
Make sure to always store deeper keys along the same path first so
|
||||
we ge a more specific match.
|
||||
*********************************************************************/
|
||||
|
||||
static struct reg_dyn_tree print_registry[] = {
|
||||
{ "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRINT/MONITORS",
|
||||
&key_monitor_fetch_keys,
|
||||
&key_monitor_store_keys,
|
||||
&key_monitor_fetch_values,
|
||||
&key_monitor_store_values },
|
||||
{ "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRINT/FORMS",
|
||||
&key_forms_fetch_keys,
|
||||
&key_forms_store_keys,
|
||||
&key_forms_fetch_values,
|
||||
&key_forms_store_values },
|
||||
{ "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRINT/PRINTERS",
|
||||
&key_printer_fetch_keys,
|
||||
&key_printer_store_keys,
|
||||
&key_printer_fetch_values,
|
||||
&key_printer_store_values },
|
||||
{ "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRINT/ENVIRONMENTS",
|
||||
&key_driver_fetch_keys,
|
||||
&key_driver_store_keys,
|
||||
&key_driver_fetch_values,
|
||||
&key_driver_store_values },
|
||||
{ "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRINT",
|
||||
&key_print_fetch_keys,
|
||||
&key_print_store_keys,
|
||||
&key_print_fetch_values,
|
||||
&key_print_store_values },
|
||||
{ "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION/PRINT/PRINTERS",
|
||||
&key_printer_fetch_keys,
|
||||
&key_printer_store_keys,
|
||||
&key_printer_fetch_values,
|
||||
&key_printer_store_values },
|
||||
{ "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION/PRINT",
|
||||
&key_print_fetch_keys,
|
||||
&key_print_store_keys,
|
||||
&key_print_fetch_values,
|
||||
&key_print_store_values },
|
||||
{ "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION/PORTS",
|
||||
&key_ports_fetch_keys,
|
||||
&key_ports_store_keys,
|
||||
&key_ports_fetch_values,
|
||||
&key_ports_store_values },
|
||||
|
||||
{ NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int match_registry_path( const char *key )
|
||||
{
|
||||
int i;
|
||||
pstring path;
|
||||
|
||||
if ( !key )
|
||||
return -1;
|
||||
|
||||
pstrcpy( path, key );
|
||||
normalize_reg_path( path );
|
||||
|
||||
for ( i=0; print_registry[i].path; i++ ) {
|
||||
if ( strncmp( path, print_registry[i].path, strlen(print_registry[i].path) ) == 0 )
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int regprint_fetch_reg_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
int i = match_registry_path( key );
|
||||
|
||||
if ( i == -1 )
|
||||
return -1;
|
||||
|
||||
return print_registry[i].fetch_subkeys( key, subkeys );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static BOOL regprint_store_reg_keys( const char *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
int i = match_registry_path( key );
|
||||
|
||||
if ( i == -1 )
|
||||
return False;
|
||||
|
||||
return print_registry[i].store_subkeys( key, subkeys );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static int regprint_fetch_reg_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
int i = match_registry_path( key );
|
||||
|
||||
if ( i == -1 )
|
||||
return -1;
|
||||
|
||||
return print_registry[i].fetch_values( key, values );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
static BOOL regprint_store_reg_values( const char *key, REGVAL_CTR *values )
|
||||
{
|
||||
int i = match_registry_path( key );
|
||||
|
||||
if ( i == -1 )
|
||||
return False;
|
||||
|
||||
return print_registry[i].store_values( key, values );
|
||||
}
|
||||
|
||||
/*
|
||||
* Table of function pointers for accessing printing data
|
||||
*/
|
||||
|
||||
REGISTRY_OPS printing_ops = {
|
||||
printing_subkey_info,
|
||||
printing_value_info,
|
||||
printing_store_subkey,
|
||||
printing_store_value,
|
||||
regprint_fetch_reg_keys,
|
||||
regprint_fetch_reg_values,
|
||||
regprint_store_reg_keys,
|
||||
regprint_store_reg_values,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user