summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-09-14 16:12:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:47 -0500
commit5b00e7c38987d8726046440e46fccd86a0d8a104 (patch)
treec8b035c26f13bd8933d5507c770111c3bd2665ca /source3/registry
parent8b6366b301d3020223fbd6ac3dad42b1476b37f9 (diff)
downloadsamba-5b00e7c38987d8726046440e46fccd86a0d8a104.tar.gz
samba-5b00e7c38987d8726046440e46fccd86a0d8a104.tar.bz2
samba-5b00e7c38987d8726046440e46fccd86a0d8a104.zip
r25162: Refactor further: add mapping functions between
REGISTRY_VALUE and struct registry_value formats for registry values. Lacking better naming, I called them regval_hilvl_to_lolvl and regval_lolvl_to_hilvl for a start. The might be useful elsewhere, so might be put into another place later on. Michael (This used to be commit 883fd7906165ca10413e4745b3beed59516adf34)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_smbconf.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/source3/registry/reg_smbconf.c b/source3/registry/reg_smbconf.c
index 06636f2b63..09d11dd969 100644
--- a/source3/registry/reg_smbconf.c
+++ b/source3/registry/reg_smbconf.c
@@ -40,6 +40,47 @@ static int smbconf_fetch_values( const char *key, REGVAL_CTR *val )
return regdb_ops.fetch_values(key, val);
}
+static WERROR regval_hilvl_to_lolvl(TALLOC_CTX *mem_ctx, const char *valname,
+ struct registry_value *src,
+ REGISTRY_VALUE **dst)
+{
+ WERROR err;
+ DATA_BLOB value_data;
+ REGISTRY_VALUE *newval = NULL;
+
+ if (dst == NULL) {
+ return WERR_INVALID_PARAM;
+ }
+
+ err = registry_push_value(mem_ctx, src, &value_data);
+ if (!W_ERROR_IS_OK(err)) {
+ DEBUG(10, ("error calling registry_push_value.\n"));
+ return err;
+ }
+
+ newval = regval_compose(mem_ctx, valname, src->type,
+ (char *)value_data.data, value_data.length);
+ if (newval == NULL) {
+ DEBUG(10, ("error composing registry value. (no memory?)\n"));
+ return WERR_NOMEM;
+ }
+
+ *dst = newval;
+ return WERR_OK;
+}
+
+static WERROR regval_lolvl_to_hilvl(TALLOC_CTX *mem_ctx, REGISTRY_VALUE *src,
+ struct registry_value **dst)
+{
+ if (dst == NULL) {
+ return WERR_INVALID_PARAM;
+ }
+
+ return registry_pull_value(mem_ctx, dst, regval_type(src),
+ regval_data_p(src), regval_size(src),
+ regval_size(src));
+}
+
/*
* Utility function used by smbconf_store_values to canonicalize
* a registry value.
@@ -55,7 +96,6 @@ static REGISTRY_VALUE *smbconf_canonicalize_regval(TALLOC_CTX *mem_ctx,
BOOL inverse;
struct registry_value *value;
WERROR err;
- DATA_BLOB value_data;
TALLOC_CTX *tmp_ctx;
REGISTRY_VALUE *newval = NULL;
@@ -71,9 +111,7 @@ static REGISTRY_VALUE *smbconf_canonicalize_regval(TALLOC_CTX *mem_ctx,
goto done;
}
- err = registry_pull_value(tmp_ctx, &value, regval_type(theval),
- regval_data_p(theval), regval_size(theval),
- regval_size(theval));
+ err = regval_lolvl_to_hilvl(tmp_ctx, theval, &value);
if (!W_ERROR_IS_OK(err)) {
goto done;
}
@@ -111,16 +149,9 @@ static REGISTRY_VALUE *smbconf_canonicalize_regval(TALLOC_CTX *mem_ctx,
value->v.sz.str = CONST_DISCARD(char *, canon_valstr);
value->v.sz.len = strlen(canon_valstr) + 1;
- err = registry_push_value(tmp_ctx, value, &value_data);
+ err = regval_hilvl_to_lolvl(mem_ctx, canon_valname, value, &newval);
if (!W_ERROR_IS_OK(err)) {
- DEBUG(10, ("error calling registry_push_value.\n"));
- goto done;
- }
-
- newval = regval_compose(mem_ctx, canon_valname, value->type,
- (char *)value_data.data, value_data.length);
- if (newval == NULL) {
- DEBUG(10, ("error composing registry value. (no memory?)\n"));
+ DEBUG(10, ("error calling regval_hilvl_to_lolvl.\n"));
goto done;
}