diff options
author | Andreas Schneider <asn@samba.org> | 2011-04-11 13:50:53 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-05-10 19:13:21 +0200 |
commit | ff5838d97aad5b283073726052456b06ecf410b2 (patch) | |
tree | 17758bb35392865491bba9ad6a4fb8a4b69046dc | |
parent | ddc28a683fcf036a279a0d3d7b23504364316fa6 (diff) | |
download | samba-ff5838d97aad5b283073726052456b06ecf410b2.tar.gz samba-ff5838d97aad5b283073726052456b06ecf410b2.tar.bz2 samba-ff5838d97aad5b283073726052456b06ecf410b2.zip |
libsmbconf: Convert smbconf_get_parameter() to sbcErr.
Signed-off-by: Michael Adam <obnox@samba.org>
-rw-r--r-- | lib/smbconf/smbconf.c | 15 | ||||
-rw-r--r-- | lib/smbconf/smbconf.h | 5 | ||||
-rw-r--r-- | lib/smbconf/smbconf_private.h | 2 | ||||
-rw-r--r-- | lib/smbconf/smbconf_txt.c | 12 | ||||
-rw-r--r-- | source3/lib/smbconf/smbconf_reg.c | 13 | ||||
-rw-r--r-- | source3/utils/net_conf.c | 13 |
6 files changed, 29 insertions, 31 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c index 786f4d32d1..02c49cc877 100644 --- a/lib/smbconf/smbconf.c +++ b/lib/smbconf/smbconf.c @@ -291,14 +291,14 @@ sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, /** * get the value of a configuration parameter as a string */ -WERROR smbconf_get_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, char **valstr) { if (valstr == NULL) { - return WERR_INVALID_PARAM; + return SBC_ERR_INVALID_PARAM; } return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr); @@ -309,23 +309,22 @@ WERROR smbconf_get_parameter(struct smbconf_ctx *ctx, * * Create [global] if it does not exist. */ -WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *param, char **valstr) { - WERROR werr; sbcErr err; err = smbconf_global_check(ctx); if (!SBC_ERROR_IS_OK(err)) { - return WERR_GENERAL_FAILURE; + return err; } - werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, - valstr); + err = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, + valstr); - return werr; + return err; } /** diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h index 1471ceca1d..15476f1460 100644 --- a/lib/smbconf/smbconf.h +++ b/lib/smbconf/smbconf.h @@ -42,6 +42,7 @@ enum _sbcErrType { typedef enum _sbcErrType sbcErr; #define SBC_ERROR_IS_OK(x) ((x) == SBC_ERR_OK) +#define SBC_ERROR_EQUAL(x,y) ((x) == (y)) struct smbconf_ctx; @@ -97,12 +98,12 @@ sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx, const char *valstr); sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, const char *param, const char *val); -WERROR smbconf_get_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, char **valstr); -WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *param, char **valstr); diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h index b11a1420ae..9bfcbe097a 100644 --- a/lib/smbconf/smbconf_private.h +++ b/lib/smbconf/smbconf_private.h @@ -52,7 +52,7 @@ struct smbconf_ops { const char *service, const char *param, const char *valstr); - WERROR (*get_parameter)(struct smbconf_ctx *ctx, + sbcErr (*get_parameter)(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c index 0f77254d38..e31009e7b2 100644 --- a/lib/smbconf/smbconf_txt.c +++ b/lib/smbconf/smbconf_txt.c @@ -482,7 +482,7 @@ static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx, /** * get the value of a configuration parameter as a string */ -static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_get_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, @@ -494,7 +494,7 @@ static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx, err = smbconf_txt_load_file(ctx); if (!SBC_ERROR_IS_OK(err)) { - return WERR_GENERAL_FAILURE; + return err; } found = smbconf_find_in_array(service, @@ -502,7 +502,7 @@ static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx, pd(ctx)->cache->num_shares, &share_index); if (!found) { - return WERR_NO_SUCH_SERVICE; + return SBC_ERR_NO_SUCH_SERVICE; } found = smbconf_reverse_find_in_array(param, @@ -510,17 +510,17 @@ static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx, pd(ctx)->cache->num_params[share_index], ¶m_index); if (!found) { - return WERR_INVALID_PARAM; + return SBC_ERR_INVALID_PARAM; } *valstr = talloc_strdup(mem_ctx, pd(ctx)->cache->param_values[share_index][param_index]); if (*valstr == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } - return WERR_OK; + return SBC_ERR_OK; } /** diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c index f7faf51e7d..42eb6d18b9 100644 --- a/source3/lib/smbconf/smbconf_reg.c +++ b/source3/lib/smbconf/smbconf_reg.c @@ -989,7 +989,7 @@ done: /** * get the value of a configuration parameter as a string */ -static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_reg_get_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, const char *param, @@ -1003,35 +1003,34 @@ static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx, err = smbconf_reg_open_service_key(mem_ctx, ctx, service, REG_KEY_READ, &key); if (!SBC_ERROR_IS_OK(err)) { - werr = WERR_NOMEM; goto done; } if (!smbconf_reg_valname_valid(param)) { - werr = WERR_INVALID_PARAM; + err = SBC_ERR_INVALID_PARAM; goto done; } if (!smbconf_value_exists(key, param)) { - werr = WERR_INVALID_PARAM; + err = SBC_ERR_INVALID_PARAM; goto done; } werr = reg_queryvalue(mem_ctx, key, param, &value); if (!W_ERROR_IS_OK(werr)) { + err = SBC_ERR_NOMEM; goto done; } *valstr = smbconf_format_registry_value(mem_ctx, value); - if (*valstr == NULL) { - werr = WERR_NOMEM; + err = SBC_ERR_NOMEM; } done: talloc_free(key); talloc_free(value); - return werr; + return err; } /** diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 4be91e35a8..187735027b 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -902,7 +902,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; - WERROR werr = WERR_OK; + sbcErr err; char *service = NULL; char *param = NULL; char *valstr = NULL; @@ -931,21 +931,20 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx, goto done; } - werr = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr); - - if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) { + err = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr); + if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) { d_fprintf(stderr, _("Error: given service '%s' does not exist.\n"), service); goto done; - } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) { + } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) { d_fprintf(stderr, _("Error: given parameter '%s' is not set.\n"), param); goto done; - } else if (!W_ERROR_IS_OK(werr)) { + } else if (!SBC_ERROR_IS_OK(err)) { d_fprintf(stderr, _("Error getting value '%s': %s.\n"), - param, win_errstr(werr)); + param, sbcErrorString(err)); goto done; } |