diff options
author | Michael Adam <obnox@samba.org> | 2008-04-08 23:58:56 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-04-10 01:29:00 +0200 |
commit | 1da629537cdd81eb499666c59b9c6260ff8a89b7 (patch) | |
tree | 7f19430e9f64160dd9ce138146c2eb37d1294b85 /source3 | |
parent | a7e06ad6253ba0b30d9b2f1393c2a6f7064f464b (diff) | |
download | samba-1da629537cdd81eb499666c59b9c6260ff8a89b7.tar.gz samba-1da629537cdd81eb499666c59b9c6260ff8a89b7.tar.bz2 samba-1da629537cdd81eb499666c59b9c6260ff8a89b7.zip |
libsmbconf: refactor get_includes on opened key into smbconf_reg_get_includes_internal()
Michael
(This used to be commit 072a3228a4e08894c67ad2983bcea3417e202773)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/smbconf/smbconf_reg.c | 96 |
1 files changed, 56 insertions, 40 deletions
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c index e790e65175..23aad44892 100644 --- a/source3/lib/smbconf/smbconf_reg.c +++ b/source3/lib/smbconf/smbconf_reg.c @@ -379,6 +379,60 @@ static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx, return result; } +static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx, + struct registry_key *key, + uint32_t *num_includes, + char ***includes) +{ + WERROR werr; + uint32_t count; + struct registry_value *value = NULL; + char **tmp_includes = NULL; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); + + if (!smbconf_value_exists(key, INCLUDES_VALNAME)) { + /* no includes */ + goto done; + } + + werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + if (value->type != REG_MULTI_SZ) { + /* wront type -- ignore */ + goto done; + } + + for (count = 0; count < value->v.multi_sz.num_strings; count++) + { + werr = smbconf_add_string_to_array(tmp_ctx, + &tmp_includes, + count, + value->v.multi_sz.strings[count]); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + + if (count > 0) { + *includes = talloc_move(mem_ctx, &tmp_includes); + if (*includes == NULL) { + werr = WERR_NOMEM; + goto done; + } + *num_includes = count; + } else { + *num_includes = 0; + *includes = NULL; + } + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} + /** * Get the values of a key as a list of value names * and a list of value strings (ordered) @@ -852,10 +906,7 @@ static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx, char ***includes) { WERROR werr; - uint32_t count; struct registry_key *key = NULL; - struct registry_value *value = NULL; - char **tmp_includes = NULL; TALLOC_CTX *tmp_ctx = talloc_stackframe(); werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service, @@ -864,43 +915,8 @@ static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx, goto done; } - if (!smbconf_value_exists(key, INCLUDES_VALNAME)) { - /* no includes */ - goto done; - } - - werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } - - if (value->type != REG_MULTI_SZ) { - /* wront type -- ignore */ - goto done; - } - - for (count = 0; count < value->v.multi_sz.num_strings; count++) - { - werr = smbconf_add_string_to_array(tmp_ctx, - &tmp_includes, - count, - value->v.multi_sz.strings[count]); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } - } - - if (count > 0) { - *includes = talloc_move(mem_ctx, &tmp_includes); - if (*includes == NULL) { - werr = WERR_NOMEM; - goto done; - } - *num_includes = count; - } else { - *num_includes = 0; - *includes = NULL; - } + werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes, + includes); done: TALLOC_FREE(tmp_ctx); |