1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

libsmbconf: Convert smbconf_get_config() to sbcErr.

Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Andreas Schneider 2011-04-11 17:43:10 +02:00 committed by Michael Adam
parent e1f0b91c5f
commit 4d391d29f8
4 changed files with 27 additions and 38 deletions

View File

@ -141,12 +141,11 @@ sbcErr smbconf_drop(struct smbconf_ctx *ctx)
* param_names : list of lists of parameter names for each share
* param_values : list of lists of parameter values for each share
*/
WERROR smbconf_get_config(struct smbconf_ctx *ctx,
sbcErr smbconf_get_config(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
uint32_t *num_shares,
struct smbconf_service ***services)
{
WERROR werr = WERR_OK;
sbcErr err;
TALLOC_CTX *tmp_ctx = NULL;
uint32_t tmp_num_shares;
@ -155,7 +154,7 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx,
uint32_t count;
if ((num_shares == NULL) || (services == NULL)) {
werr = WERR_INVALID_PARAM;
err = SBC_ERR_INVALID_PARAM;
goto done;
}
@ -164,15 +163,13 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx,
err = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares,
&tmp_share_names);
if (!SBC_ERROR_IS_OK(err)) {
werr = WERR_GENERAL_FAILURE;
goto done;
}
tmp_services = talloc_array(tmp_ctx, struct smbconf_service *,
tmp_num_shares);
if (tmp_services == NULL) {
werr = WERR_NOMEM;
err = SBC_ERR_NOMEM;
goto done;
}
@ -181,12 +178,11 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx,
tmp_share_names[count],
&tmp_services[count]);
if (!SBC_ERROR_IS_OK(err)) {
werr = WERR_GENERAL_FAILURE;
goto done;
}
}
werr = WERR_OK;
err = SBC_ERR_OK;
*num_shares = tmp_num_shares;
if (tmp_num_shares > 0) {
@ -197,7 +193,7 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx,
done:
talloc_free(tmp_ctx);
return werr;
return err;
}
/**

View File

@ -76,7 +76,7 @@ void smbconf_shutdown(struct smbconf_ctx *ctx);
bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
const char *service, const char *param);
sbcErr smbconf_drop(struct smbconf_ctx *ctx);
WERROR smbconf_get_config(struct smbconf_ctx *ctx,
sbcErr smbconf_get_config(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
uint32_t *num_shares,
struct smbconf_service ***services);

View File

@ -7313,7 +7313,7 @@ static bool process_registry_globals(void)
bool process_registry_shares(void)
{
WERROR werr;
sbcErr err;
uint32_t count;
struct smbconf_service **service = NULL;
uint32_t num_shares = 0;
@ -7325,8 +7325,8 @@ bool process_registry_shares(void)
goto done;
}
werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
if (!W_ERROR_IS_OK(werr)) {
err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
if (!SBC_ERROR_IS_OK(err)) {
goto done;
}

View File

@ -174,13 +174,12 @@ static int net_conf_delincludes_usage(struct net_context *c, int argc,
/**
* This functions process a service previously loaded with libsmbconf.
*/
static WERROR import_process_service(struct net_context *c,
static sbcErr import_process_service(struct net_context *c,
struct smbconf_ctx *conf_ctx,
struct smbconf_service *service)
{
uint32_t idx;
WERROR werr = WERR_OK;
sbcErr err;
sbcErr err = SBC_ERR_OK;
uint32_t num_includes = 0;
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@ -203,13 +202,11 @@ static WERROR import_process_service(struct net_context *c,
if (smbconf_share_exists(conf_ctx, service->name)) {
err = smbconf_delete_share(conf_ctx, service->name);
if (!SBC_ERROR_IS_OK(err)) {
werr = WERR_GENERAL_FAILURE;
goto done;
}
}
err = smbconf_create_share(conf_ctx, service->name);
if (!SBC_ERROR_IS_OK(err)) {
werr = WERR_GENERAL_FAILURE;
goto done;
}
@ -220,13 +217,13 @@ static WERROR import_process_service(struct net_context *c,
char *,
num_includes+1);
if (includes == NULL) {
werr = WERR_NOMEM;
err = SBC_ERR_NOMEM;
goto done;
}
includes[num_includes] = talloc_strdup(includes,
service->param_values[idx]);
if (includes[num_includes] == NULL) {
werr = WERR_NOMEM;
err = SBC_ERR_NOMEM;
goto done;
}
num_includes++;
@ -240,7 +237,6 @@ static WERROR import_process_service(struct net_context *c,
_("Error in section [%s], parameter \"%s\": %s\n"),
service->name, service->param_names[idx],
sbcErrorString(err));
werr = WERR_NOMEM;
goto done;
}
}
@ -249,14 +245,13 @@ static WERROR import_process_service(struct net_context *c,
err = smbconf_set_includes(conf_ctx, service->name, num_includes,
(const char **)includes);
if (!SBC_ERROR_IS_OK(err)) {
werr = WERR_NOMEM;
goto done;
}
werr = WERR_OK;
err = SBC_ERR_OK;
done:
TALLOC_FREE(mem_ctx);
return werr;
return err;
}
@ -269,7 +264,7 @@ done:
static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
WERROR werr = WERR_OK;
sbcErr err;
int ret = -1;
TALLOC_CTX *mem_ctx;
uint32_t num_shares;
@ -283,10 +278,10 @@ static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
if (!W_ERROR_IS_OK(werr)) {
err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error getting config: %s\n"),
win_errstr(werr));
sbcErrorString(err));
goto done;
}
@ -324,7 +319,6 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
char *conf_source = NULL;
TALLOC_CTX *mem_ctx;
struct smbconf_ctx *txt_ctx;
WERROR werr;
sbcErr err;
if (c->display_usage)
@ -361,7 +355,6 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error loading file '%s': %s\n"), filename,
sbcErrorString(err));
werr = WERR_NO_SUCH_SERVICE;
goto done;
}
@ -383,22 +376,22 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
err = smbconf_transaction_start(conf_ctx);
if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
win_errstr(werr));
sbcErrorString(err));
goto done;
}
werr = import_process_service(c, conf_ctx, service);
if (!W_ERROR_IS_OK(werr)) {
err = import_process_service(c, conf_ctx, service);
if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
} else {
struct smbconf_service **services = NULL;
uint32_t num_shares, sidx;
werr = smbconf_get_config(txt_ctx, mem_ctx,
err = smbconf_get_config(txt_ctx, mem_ctx,
&num_shares,
&services);
if (!W_ERROR_IS_OK(werr)) {
if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
if (!c->opt_testmode) {
@ -423,9 +416,9 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
for (sidx = 0; sidx < num_shares; sidx++) {
werr = import_process_service(c, conf_ctx,
services[sidx]);
if (!W_ERROR_IS_OK(werr)) {
err = import_process_service(c, conf_ctx,
services[sidx]);
if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}