mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
Add a function libnet_smbconf_get_config() to libnet_conf.c
This gets the whole config as a set of lists (of share names and corresponding lists of parameter names and values). The function is an aggregate of libnet_smbconf_get_share_names() and libnet_smbconf_getshare(). Michael (This used to be commit 94e97a72548a7f76a5273346d472e3ba5b24795a)
This commit is contained in:
parent
df93c1aa57
commit
fe47e2e855
@ -421,6 +421,90 @@ done:
|
||||
return werr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the whole configuration as lists of strings with counts:
|
||||
*
|
||||
* num_shares : number of shares
|
||||
* share_names : list of length num_shares of share names
|
||||
* num_params : list of length num_shares of parameter counts for each share
|
||||
* param_names : list of lists of parameter names for each share
|
||||
* param_values : list of lists of parameter values for each share
|
||||
*/
|
||||
WERROR libnet_smbconf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
|
||||
char ***share_names, uint32_t **num_params,
|
||||
char ****param_names, char ****param_values)
|
||||
{
|
||||
WERROR werr = WERR_OK;
|
||||
TALLOC_CTX *tmp_ctx = NULL;
|
||||
uint32_t tmp_num_shares;
|
||||
char **tmp_share_names;
|
||||
uint32_t *tmp_num_params;
|
||||
char ***tmp_param_names;
|
||||
char ***tmp_param_values;
|
||||
uint32_t count;
|
||||
|
||||
if ((num_shares == NULL) || (share_names == NULL) ||
|
||||
(num_params == NULL) || (param_names == NULL) ||
|
||||
(param_values == NULL))
|
||||
{
|
||||
werr = WERR_INVALID_PARAM;
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp_ctx = talloc_new(mem_ctx);
|
||||
if (tmp_ctx == NULL) {
|
||||
werr = WERR_NOMEM;
|
||||
goto done;
|
||||
}
|
||||
|
||||
werr = libnet_smbconf_get_share_names(tmp_ctx, &tmp_num_shares,
|
||||
&tmp_share_names);
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp_num_params = TALLOC_ARRAY(tmp_ctx, uint32_t, tmp_num_shares);
|
||||
tmp_param_names = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares);
|
||||
tmp_param_values = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares);
|
||||
|
||||
if ((tmp_num_params == NULL) || (tmp_param_names == NULL) ||
|
||||
(tmp_param_values == NULL))
|
||||
{
|
||||
werr = WERR_NOMEM;
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (count = 0; count < tmp_num_shares; count++) {
|
||||
werr = libnet_smbconf_getshare(mem_ctx, tmp_share_names[count],
|
||||
&tmp_num_params[count],
|
||||
&tmp_param_names[count],
|
||||
&tmp_param_values[count]);
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
werr = WERR_OK;
|
||||
|
||||
*num_shares = tmp_num_shares;
|
||||
if (tmp_num_shares > 0) {
|
||||
*share_names = talloc_move(mem_ctx, &tmp_share_names);
|
||||
*num_params = talloc_move(mem_ctx, &tmp_num_params);
|
||||
*param_names = talloc_move(mem_ctx, &tmp_param_names);
|
||||
*param_values = talloc_move(mem_ctx, &tmp_param_values);
|
||||
} else {
|
||||
*share_names = NULL;
|
||||
*num_params = NULL;
|
||||
*param_names = NULL;
|
||||
*param_values = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
return werr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the list of share names defined in the configuration.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user