libsmbconf: Convert smbconf_get_config() to sbcErr.
authorAndreas Schneider <asn@samba.org>
Mon, 11 Apr 2011 15:43:10 +0000 (17:43 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 10 May 2011 17:13:22 +0000 (19:13 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
lib/smbconf/smbconf.c
lib/smbconf/smbconf.h
source3/param/loadparm.c
source3/utils/net_conf.c

index c81af36cdbdf5674f22ab49ad7aeab40377d0d2d..e0441ed9857f1d09bf4ca69a95b416d8ce5535a2 100644 (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;
 }
 
 /**
index f5dd922ed165e25170531a6afb09bebc1d804d8a..467b5caa795d481af69ad23d75edddc36f1bbbff 100644 (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);
index d9608babc885bf83586af38fb200504d8f406c68..2f67c502d2b58d40eb9a0cdf4242aff419d07f60 100644 (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;
        }
 
index 7ca58ee2d53df25858d66bba48e41707a5db73ec..2c6ccda110844a339c08c37b6a40f94d2ba7174d 100644 (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;
                        }