virtual registry framework with initial printing hooks.
[Samba.git] / source / registry / reg_frontend.c
blob76d67fdfc9755cc6de068ca5d50c46e7d157dde8
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2002.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* Implementation of registry frontend view functions. */
23 #include "includes.h"
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_RPC_SRV
28 extern REGISTRY_OPS printing_ops;
30 /* array of REGISTRY_HOOK's which are read into a tree for easy access */
33 REGISTRY_HOOK reg_hooks[] = {
34 { KEY_PRINTING, &printing_ops },
35 { NULL, NULL }
39 /***********************************************************************
40 Open the registry database and initialize the REGISTRY_HOOK cache
41 ***********************************************************************/
43 BOOL init_registry( void )
45 int i;
47 if ( !init_registry_db() ) {
48 DEBUG(0,("init_registry: failed to initialize the registry tdb!\n"));
49 return False;
52 /* build the cache tree of registry hooks */
54 reghook_cache_init();
56 for ( i=0; reg_hooks[i].keyname; i++ ) {
57 if ( !reghook_cache_add(&reg_hooks[i]) )
58 return False;
61 reghook_dump_cache(20);
63 return True;
69 /***********************************************************************
70 High level wrapper function for storing registry subkeys
71 ***********************************************************************/
73 BOOL store_reg_keys( REGISTRY_KEY *key, char **subkeys, uint32 num_subkeys )
75 return regdb_store_reg_keys( key->name, subkeys, num_subkeys );
79 /***********************************************************************
80 High level wrapper function for storing registry values
81 ***********************************************************************/
83 BOOL store_reg_values( REGISTRY_KEY *key, REGISTRY_VALUE **val, uint32 num_values )
85 return True;
89 /***********************************************************************
90 High level wrapper function for enumerating registry subkeys
91 ***********************************************************************/
93 int fetch_reg_keys( REGISTRY_KEY *key, char **subkeys )
95 int num_subkeys;
97 if ( key->hook && key->hook->ops && key->hook->ops->subkey_fn )
98 num_subkeys = key->hook->ops->subkey_fn( key->name, subkeys );
99 else
100 num_subkeys = regdb_fetch_reg_keys( key->name, subkeys );
102 return num_subkeys;
105 /***********************************************************************
106 High level wrapper function for retreiving a specific registry subkey
107 given and index.
108 ***********************************************************************/
110 BOOL fetch_reg_keys_specific( REGISTRY_KEY *key, char** subkey, uint32 key_index )
112 BOOL result;
114 if ( key->hook && key->hook->ops && key->hook->ops->subkey_specific_fn )
115 result = key->hook->ops->subkey_specific_fn( key->name, subkey, key_index );
116 else
117 result = regdb_fetch_reg_keys_specific( key->name, subkey, key_index );
119 return result;
123 /***********************************************************************
124 High level wrapper function for enumerating registry values
125 ***********************************************************************/
127 int fetch_reg_values( REGISTRY_KEY *key, REGISTRY_VALUE **val )
129 int num_values;
131 if ( key->hook && key->hook->ops && key->hook->ops->value_fn )
132 num_values = key->hook->ops->value_fn( key->name, val );
133 else
134 num_values = regdb_fetch_reg_values( key->name, val );
136 return num_values;