summaryrefslogtreecommitdiff
path: root/source4/lib/registry/common
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-04-05 09:17:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:50:40 -0500
commit69c19afb6226e93a244490fa582200364a3b7069 (patch)
treefcc1c040cfc6dd878a7f193d568730f264198912 /source4/lib/registry/common
parentb087ed482115520a6c18e9a1c02accce0014d80f (diff)
downloadsamba-69c19afb6226e93a244490fa582200364a3b7069.tar.gz
samba-69c19afb6226e93a244490fa582200364a3b7069.tar.bz2
samba-69c19afb6226e93a244490fa582200364a3b7069.zip
r31: More registry updates. regdiff/regpatch work now.
(This used to be commit 98224f5436695eb265f5d997cf4bc9cf735a4fb9)
Diffstat (limited to 'source4/lib/registry/common')
-rw-r--r--source4/lib/registry/common/reg_interface.c65
-rw-r--r--source4/lib/registry/common/reg_objects.c2
2 files changed, 62 insertions, 5 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index dc49dab4c1..d40a855f89 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -187,6 +187,8 @@ REG_VAL *reg_key_get_value_by_index(REG_KEY *key, int idx)
int reg_key_num_subkeys(REG_KEY *key)
{
+ if(!key) return 0;
+
if(!key->handle->functions->num_subkeys) {
if(!key->cache_subkeys)
key->handle->functions->fetch_subkeys(key, &key->cache_subkeys_count, &key->cache_subkeys);
@@ -306,8 +308,12 @@ REG_VAL *reg_key_get_value_by_name(REG_KEY *key, const char *name)
BOOL reg_key_del(REG_KEY *key)
{
- if(key->handle->functions->del_key)
- return key->handle->functions->del_key(key);
+ if(key->handle->functions->del_key) {
+ if(key->handle->functions->del_key(key)) {
+ free_cached_keys(key);
+ return True;
+ }
+ }
return False;
}
@@ -349,17 +355,53 @@ BOOL reg_val_del(REG_VAL *val)
return False;
}
- return val->handle->functions->del_value(val);
+ if(val->handle->functions->del_value(val)) {
+ free_cached_values(val->parent);
+ return True;
+ }
+ return False;
+}
+
+BOOL reg_key_add_name_recursive(REG_KEY *parent, const char *path)
+{
+ REG_KEY *cur, *prevcur = parent;
+ char *begin = (char *)path, *end;
+
+ while(1) {
+ end = strchr(begin, '\\');
+ if(end) *end = '\0';
+ cur = reg_key_get_subkey_by_name(prevcur, begin);
+ if(!cur) {
+ if(!reg_key_add_name(prevcur, begin)) { printf("foo\n"); return False; }
+ cur = reg_key_get_subkey_by_name(prevcur, begin);
+ if(!cur) {
+ DEBUG(0, ("Can't find key after adding it : %s\n", begin));
+ return False;
+ }
+ }
+
+ if(!end) break;
+ *end = '\\';
+ begin = end+1;
+ prevcur = cur;
+ }
+ return True;
}
BOOL reg_key_add_name(REG_KEY *parent, const char *name)
{
+ if (!parent) return False;
+
if (!parent->handle->functions->add_key) {
DEBUG(1, ("Backend '%s' doesn't support method add_key\n", parent->handle->functions->name));
return False;
}
- return parent->handle->functions->add_key(parent, name);
+ if(parent->handle->functions->add_key(parent, name)) {
+ free_cached_keys(parent);
+ return True;
+ }
+ return False;
}
BOOL reg_val_update(REG_VAL *val, int type, void *data, int len)
@@ -377,6 +419,7 @@ BOOL reg_val_update(REG_VAL *val, int type, void *data, int len)
new = val->handle->functions->add_value(val->parent, val->name, type, data, len);
memcpy(val, new, sizeof(REG_VAL));
+ free_cached_values(val->parent);
return True;
}
@@ -419,5 +462,19 @@ REG_VAL *reg_key_add_value(REG_KEY *key, const char *name, int type, void *value
ret = key->handle->functions->add_value(key, name, type, value, vallen);
ret->parent = key;
ret->handle = key->handle;
+ free_cached_values(key);
return ret;
}
+
+void free_cached_values(REG_KEY *key)
+{
+ free(key->cache_values); key->cache_values = NULL;
+ key->cache_values_count = 0;
+}
+
+
+void free_cached_keys(REG_KEY *key)
+{
+ free(key->cache_subkeys); key->cache_subkeys = NULL;
+ key->cache_subkeys_count = 0;
+}
diff --git a/source4/lib/registry/common/reg_objects.c b/source4/lib/registry/common/reg_objects.c
index 911dc15c8e..8de0065da0 100644
--- a/source4/lib/registry/common/reg_objects.c
+++ b/source4/lib/registry/common/reg_objects.c
@@ -161,7 +161,7 @@ char *reg_val_get_path(REG_VAL *v)
return NULL;
}
-char *reg_key_get_path(REG_KEY *k)
+const char *reg_key_get_path(REG_KEY *k)
{
SMB_REG_ASSERT(k);
return k->path;