00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "includes.h"
00024 #include "adt_tree.h"
00025
00026 #undef DBGC_CLASS
00027 #define DBGC_CLASS DBGC_RPC_SRV
00028
00029 static SORTED_TREE *cache_tree;
00030 extern REGISTRY_OPS regdb_ops;
00031 static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, ®db_ops };
00032
00033
00034
00035
00036
00037 BOOL reghook_cache_init( void )
00038 {
00039 cache_tree = pathtree_init( &default_hook, NULL );
00040
00041 return ( cache_tree == NULL );
00042 }
00043
00044
00045
00046
00047
00048
00049 BOOL reghook_cache_add( REGISTRY_HOOK *hook )
00050 {
00051 pstring key;
00052
00053 if ( !hook )
00054 return False;
00055
00056 pstrcpy( key, "\\");
00057 pstrcat( key, hook->keyname );
00058
00059 pstring_sub( key, "\\", "/" );
00060
00061 DEBUG(10,("reghook_cache_add: Adding key [%s]\n", key));
00062
00063 return pathtree_add( cache_tree, key, hook );
00064 }
00065
00066
00067
00068
00069
00070 REGISTRY_HOOK* reghook_cache_find( const char *keyname )
00071 {
00072 char *key;
00073 int len;
00074 REGISTRY_HOOK *hook;
00075
00076 if ( !keyname )
00077 return NULL;
00078
00079
00080
00081 len = strlen( keyname );
00082 if ( !(key = (char *)SMB_MALLOC( len + 2 )) ) {
00083 DEBUG(0,("reghook_cache_find: malloc failed for string [%s] !?!?!\n",
00084 keyname));
00085 return NULL;
00086 }
00087
00088 *key = '\\';
00089 strncpy( key+1, keyname, len+1);
00090
00091
00092
00093 string_sub( key, "\\", "/", 0 );
00094
00095 DEBUG(10,("reghook_cache_find: Searching for keyname [%s]\n", key));
00096
00097 hook = (REGISTRY_HOOK *)pathtree_find( cache_tree, key ) ;
00098
00099 SAFE_FREE( key );
00100
00101 return hook;
00102 }
00103
00104
00105
00106
00107
00108 void reghook_dump_cache( int debuglevel )
00109 {
00110 DEBUG(debuglevel,("reghook_dump_cache: Starting cache dump now...\n"));
00111
00112 pathtree_print_keys( cache_tree, debuglevel );
00113 }