diff options
author | Michael Adam <obnox@samba.org> | 2007-12-29 03:38:13 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2007-12-29 12:32:16 +0100 |
commit | f8c39cbb7b3e4df3c07735575bc5f31717b22f66 (patch) | |
tree | d97d1405def821cc67689f7132a875cb3726bfc1 /source3/libnet | |
parent | 40bf6730aaca0409d17619c49e9eea59d68a6f10 (diff) | |
download | samba-f8c39cbb7b3e4df3c07735575bc5f31717b22f66.tar.gz samba-f8c39cbb7b3e4df3c07735575bc5f31717b22f66.tar.bz2 samba-f8c39cbb7b3e4df3c07735575bc5f31717b22f66.zip |
Move functionality of net_conf_showshare() to libnet_conf.c
The functionality is moved to a new function libnet_smbconf_getshare().
This returns the parameters of the given share as two lists: the list
of parameter names and the list of matching (formatted) parameter values.
The retrieval and formatting is done in a new internal helper function
libnet_smbconf_reg_get_values() that is to become the replacement for
list_values() from net_conf.c once functionality of net_conf_list() has
been moved to libnet_conf, too.
Michael
(This used to be commit 198232bd525cfac933b4885e6b330ebf4ac2c8ae)
Diffstat (limited to 'source3/libnet')
-rw-r--r-- | source3/libnet/libnet_conf.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index a8a8e01538..ca25a5cc50 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -266,6 +266,71 @@ char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, return result; } +/** + * Get the values of a key as a list of value names + * and a list of value strings (ordered) + */ +static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, + struct registry_key *key, + uint32_t *num_values, + char ***value_names, + char ***value_strings) +{ + TALLOC_CTX *tmp_ctx; + WERROR werr = WERR_OK; + uint32_t count; + struct registry_value *valvalue = NULL; + char *valname = NULL; + char **tmp_valnames = NULL; + char **tmp_valstrings = NULL; + + if ((num_values == NULL) || (value_names == NULL) || + (value_strings == NULL)) + { + werr = WERR_INVALID_PARAM; + goto done; + } + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + for (count = 0; + W_ERROR_IS_OK(werr = reg_enumvalue(tmp_ctx, key, count, &valname, + &valvalue)); + count++) + { + tmp_valnames = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valnames, + char *, count + 1); + tmp_valstrings = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valstrings, + char *, count + 1); + if ((tmp_valstrings == NULL) || (tmp_valnames == NULL)) { + werr = WERR_NOMEM; + goto done; + } + tmp_valnames[count] = talloc_strdup(tmp_valnames, valname); + tmp_valstrings[count] = + libnet_smbconf_format_registry_value(tmp_valstrings, + valvalue); + } + if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { + goto done; + } + + werr = WERR_OK; + + *num_values = count - 1; + if (count > 0) { + *value_names = talloc_move(mem_ctx, &tmp_valnames); + *value_strings = talloc_move(mem_ctx, &tmp_valstrings); + } + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} /********************************************************************** * @@ -320,6 +385,30 @@ done: } /** + * get a definition of a share (service) from configuration. + */ +WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, + uint32_t *num_params, char ***param_names, + char ***param_values) +{ + WERROR werr = WERR_OK; + struct registry_key *key = NULL; + + werr = libnet_smbconf_reg_open_path(mem_ctx, servicename, REG_KEY_READ, + &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = libnet_smbconf_reg_get_values(mem_ctx, key, num_params, + param_names, param_values); + +done: + TALLOC_FREE(key); + return werr; +} + +/** * delete a service from configuration */ WERROR libnet_smbconf_delshare(const char *servicename) |