From 1c65c98f3350951fe9f87a942b4c8a8094c8b781 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 8 Jul 2009 13:58:52 +0200 Subject: s3:registry: refactor adding of builtin reg values out into regdb_ctr_add_value(). For readability. Michael --- source3/registry/reg_backend_db.c | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'source3/registry/reg_backend_db.c') diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index bed9535f17..d04d34bac0 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -240,6 +240,31 @@ WERROR init_registry_key(const char *add_path) Open the registry data in the tdb ***********************************************************************/ +static void regdb_ctr_add_value(struct regval_ctr *ctr, + struct builtin_regkey_value *value) +{ + UNISTR2 data; + + switch(value->type) { + case REG_DWORD: + regval_ctr_addvalue(ctr, value->valuename, REG_DWORD, + (char*)&value->data.dw_value, + sizeof(uint32)); + break; + + case REG_SZ: + init_unistr2(&data, value->data.string, UNI_STR_TERMINATE); + regval_ctr_addvalue(ctr, value->valuename, REG_SZ, + (char*)data.buffer, + data.uni_str_len*sizeof(uint16)); + break; + + default: + DEBUG(0, ("regdb_ctr_add_value: invalid value type in " + "registry values [%d]\n", value->type)); + } +} + static NTSTATUS init_registry_data_action(struct db_context *db, void *private_data) { @@ -247,7 +272,6 @@ static NTSTATUS init_registry_data_action(struct db_context *db, TALLOC_CTX *frame = talloc_stackframe(); struct regval_ctr *values; int i; - UNISTR2 data; /* loop over all of the predefined paths and add each component */ @@ -281,32 +305,8 @@ static NTSTATUS init_registry_data_action(struct db_context *db, if (!regval_ctr_key_exists(values, builtin_registry_values[i].valuename)) { - switch(builtin_registry_values[i].type) { - case REG_DWORD: - regval_ctr_addvalue(values, - builtin_registry_values[i].valuename, - REG_DWORD, - (char*)&builtin_registry_values[i].data.dw_value, - sizeof(uint32)); - break; - - case REG_SZ: - init_unistr2(&data, - builtin_registry_values[i].data.string, - UNI_STR_TERMINATE); - regval_ctr_addvalue(values, - builtin_registry_values[i].valuename, - REG_SZ, - (char*)data.buffer, - data.uni_str_len*sizeof(uint16)); - break; - - default: - DEBUG(0, ("init_registry_data: invalid value " - "type in builtin_registry_values " - "[%d]\n", - builtin_registry_values[i].type)); - } + regdb_ctr_add_value(values, + &builtin_registry_values[i]); regdb_store_values_internal(db, builtin_registry_values[i].path, values); -- cgit