From b319bdd32f49f32b6d27681e1a23dfb6ba4bb878 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 30 Jun 2005 02:59:29 +0000 Subject: 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 used to be commit 28c7293ee9e68b913faf8d74d63f73e09087169b) --- source3/registry/reg_printing.c | 461 +++++++++++++++++++++++++++++----------- 1 file changed, 331 insertions(+), 130 deletions(-) (limited to 'source3/registry/reg_printing.c') diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index 6fedb524d6..275532b042 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -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[%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; iwidth; - 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; iwidth; - 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 ) { - char *path; - int num_values = 0; + 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 ) +{ + 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; iwidth; + 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 ); + 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; iwidth; + 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 ); - /* top level key */ - - if ( strequal( key, KEY_PRINTING_PORTS ) ) - num_values = fill_ports_values( val ); - - return num_values; + return regval_ctr_numvals( values ); +} + +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_subkey( const char *key, REGSUBKEY_CTR *subkeys ) +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; } /********************************************************************** - 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_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