/**
* 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);
*
* 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;
}
/**
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;
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);
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,
/**
* 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,
err = smbconf_txt_load_file(ctx);
if (!SBC_ERROR_IS_OK(err)) {
- return WERR_GENERAL_FAILURE;
+ return err;
}
found = smbconf_find_in_array(service,
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,
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;
}
/**
/**
* 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,
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;
}
/**
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
char *valstr = NULL;
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;
}