registry/reg_cachehook.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  Virtual Windows Registry Layer
00004  *  Copyright (C) Gerald Carter                     2002.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *  
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *  
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 /* Implementation of registry hook cache tree */
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;          /* these are the default */
00031 static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, &regdb_ops };
00032 
00033 /**********************************************************************
00034  Initialize the cache tree
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  Add a new REGISTRY_HOOK to the cache.  Note that the keyname
00046  is not in the exact format that a SORTED_TREE expects.
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  Initialize the cache tree
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         /* prepend the string with a '\' character */
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         /* swap to a form understood by the SORTED_TREE */
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  Initialize the cache tree
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 }

Sambaに対してSat Aug 29 21:23:15 2009に生成されました。  doxygen 1.4.7