diff options
Diffstat (limited to 'lib/smbconf')
-rw-r--r-- | lib/smbconf/smbconf.c | 186 | ||||
-rw-r--r-- | lib/smbconf/smbconf.h | 438 | ||||
-rw-r--r-- | lib/smbconf/smbconf_private.h | 36 | ||||
-rw-r--r-- | lib/smbconf/smbconf_txt.c | 205 | ||||
-rw-r--r-- | lib/smbconf/smbconf_txt.h | 2 | ||||
-rw-r--r-- | lib/smbconf/smbconf_util.c | 26 |
6 files changed, 660 insertions, 233 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c index 80fe9aac37..e0441ed985 100644 --- a/lib/smbconf/smbconf.c +++ b/lib/smbconf/smbconf.c @@ -27,12 +27,13 @@ * **********************************************************************/ -static WERROR smbconf_global_check(struct smbconf_ctx *ctx) +static sbcErr smbconf_global_check(struct smbconf_ctx *ctx) { if (!smbconf_share_exists(ctx, GLOBAL_NAME)) { return smbconf_create_share(ctx, GLOBAL_NAME); } - return WERR_OK; + + return SBC_ERR_OK; } @@ -42,6 +43,41 @@ static WERROR smbconf_global_check(struct smbconf_ctx *ctx) * **********************************************************************/ +const char *sbcErrorString(sbcErr error) +{ + switch (error) { + case SBC_ERR_OK: + return "SBC_ERR_OK"; + case SBC_ERR_NOT_IMPLEMENTED: + return "SBC_ERR_NOT_IMPLEMENTED"; + case SBC_ERR_NOT_SUPPORTED: + return "SBC_ERR_NOT_SUPPORTED"; + case SBC_ERR_UNKNOWN_FAILURE: + return "SBC_ERR_UNKNOWN_FAILURE"; + case SBC_ERR_NOMEM: + return "SBC_ERR_NOMEM"; + case SBC_ERR_INVALID_PARAM: + return "SBC_ERR_INVALID_PARAM"; + case SBC_ERR_BADFILE: + return "SBC_ERR_BADFILE"; + case SBC_ERR_NO_SUCH_SERVICE: + return "SBC_ERR_NO_SUCH_SERVICE"; + case SBC_ERR_IO_FAILURE: + return "SBC_ERR_IO_FAILURE"; + case SBC_ERR_CAN_NOT_COMPLETE: + return "SBC_ERR_CAN_NOT_COMPLETE"; + case SBC_ERR_NO_MORE_ITEMS: + return "SBC_ERR_NO_MORE_ITEMS"; + case SBC_ERR_FILE_EXISTS: + return "SBC_ERR_FILE_EXISTS"; + case SBC_ERR_ACCESS_DENIED: + return "SBC_ERR_ACCESS_DENIED"; + } + + return "unknown sbcErr value"; +} + + /** * Tell whether the backend requires messaging to be set up * for the backend to work correctly. @@ -91,7 +127,7 @@ bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn, /** * Drop the whole configuration (restarting empty). */ -WERROR smbconf_drop(struct smbconf_ctx *ctx) +sbcErr smbconf_drop(struct smbconf_ctx *ctx) { return ctx->ops->drop(ctx); } @@ -105,12 +141,12 @@ WERROR 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; char **tmp_share_names; @@ -118,36 +154,35 @@ 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; } tmp_ctx = talloc_stackframe(); - werr = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares, - &tmp_share_names); - if (!W_ERROR_IS_OK(werr)) { + err = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares, + &tmp_share_names); + if (!SBC_ERROR_IS_OK(err)) { 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; } for (count = 0; count < tmp_num_shares; count++) { - werr = smbconf_get_share(ctx, tmp_services, - tmp_share_names[count], - &tmp_services[count]); - if (!W_ERROR_IS_OK(werr)) { + err = smbconf_get_share(ctx, tmp_services, + tmp_share_names[count], + &tmp_services[count]); + if (!SBC_ERROR_IS_OK(err)) { goto done; } } - werr = WERR_OK; + err = SBC_ERR_OK; *num_shares = tmp_num_shares; if (tmp_num_shares > 0) { @@ -158,13 +193,13 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx, done: talloc_free(tmp_ctx); - return werr; + return err; } /** * get the list of share names defined in the configuration. */ -WERROR smbconf_get_share_names(struct smbconf_ctx *ctx, +sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names) @@ -185,11 +220,11 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx, /** * Add a service if it does not already exist. */ -WERROR smbconf_create_share(struct smbconf_ctx *ctx, +sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename) { if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) { - return WERR_FILE_EXISTS; + return SBC_ERR_FILE_EXISTS; } return ctx->ops->create_share(ctx, servicename); @@ -198,7 +233,7 @@ WERROR smbconf_create_share(struct smbconf_ctx *ctx, /** * get a definition of a share (service) from configuration. */ -WERROR smbconf_get_share(struct smbconf_ctx *ctx, +sbcErr smbconf_get_share(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *servicename, struct smbconf_service **service) @@ -209,10 +244,10 @@ WERROR smbconf_get_share(struct smbconf_ctx *ctx, /** * delete a service from configuration */ -WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename) +sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename) { if (!smbconf_share_exists(ctx, servicename)) { - return WERR_NO_SUCH_SERVICE; + return SBC_ERR_NO_SUCH_SERVICE; } return ctx->ops->delete_share(ctx, servicename); @@ -221,7 +256,7 @@ WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename) /** * set a configuration parameter to the value provided. */ -WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx, const char *service, const char *param, const char *valstr) @@ -235,30 +270,31 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, * * This also creates [global] when it does not exist. */ -WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, const char *param, const char *val) { - WERROR werr; + sbcErr err; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } + err = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val); - return werr; + return err; } /** * 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); @@ -269,26 +305,28 @@ 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; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, - valstr); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } - return werr; + err = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, + valstr); + + return err; } /** * delete a parameter from configuration */ -WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param) { return ctx->ops->delete_parameter(ctx, service, param); @@ -299,20 +337,21 @@ WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, * * Create [global] if it does not exist. */ -WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, const char *param) { - WERROR werr; + sbcErr err; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } + err = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); - return werr; + return err; } -WERROR smbconf_get_includes(struct smbconf_ctx *ctx, +sbcErr smbconf_get_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, uint32_t *num_includes, char ***includes) @@ -321,72 +360,75 @@ WERROR smbconf_get_includes(struct smbconf_ctx *ctx, includes); } -WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx, +sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_includes, char ***includes) { - WERROR werr; + sbcErr err; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME, - num_includes, includes); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } + err = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME, + num_includes, includes); - return werr; + return err; } -WERROR smbconf_set_includes(struct smbconf_ctx *ctx, +sbcErr smbconf_set_includes(struct smbconf_ctx *ctx, const char *service, uint32_t num_includes, const char **includes) { return ctx->ops->set_includes(ctx, service, num_includes, includes); } -WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx, +sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx, uint32_t num_includes, const char **includes) { - WERROR werr; + sbcErr err; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_set_includes(ctx, GLOBAL_NAME, - num_includes, includes); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } + err = smbconf_set_includes(ctx, GLOBAL_NAME, + num_includes, includes); - return werr; + return err; } -WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service) +sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service) { return ctx->ops->delete_includes(ctx, service); } -WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx) +sbcErr smbconf_delete_global_includes(struct smbconf_ctx *ctx) { - WERROR werr; + sbcErr err; - werr = smbconf_global_check(ctx); - if (W_ERROR_IS_OK(werr)) { - werr = smbconf_delete_includes(ctx, GLOBAL_NAME); + err = smbconf_global_check(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } + err = smbconf_delete_includes(ctx, GLOBAL_NAME); - return werr; + return err; } -WERROR smbconf_transaction_start(struct smbconf_ctx *ctx) +sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx) { return ctx->ops->transaction_start(ctx); } -WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx) +sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx) { return ctx->ops->transaction_commit(ctx); } -WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx) +sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx) { return ctx->ops->transaction_cancel(ctx); } diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h index 517302ac88..7f62b06af4 100644 --- a/lib/smbconf/smbconf.h +++ b/lib/smbconf/smbconf.h @@ -20,6 +20,39 @@ #ifndef __LIBSMBCONF_H__ #define __LIBSMBCONF_H__ +/** + * @defgroup libsmbconf The smbconf API + * + * libsmbconf is a library to read or, based on the backend, modify the Samba + * configuration. + * + * @{ + */ + +/** + * @brief Status codes returned from smbconf functions + */ +enum _sbcErrType { + SBC_ERR_OK = 0, /**< Successful completion **/ + SBC_ERR_NOT_IMPLEMENTED, /**< Function not implemented **/ + SBC_ERR_NOT_SUPPORTED, /**< Function not supported **/ + SBC_ERR_UNKNOWN_FAILURE, /**< General failure **/ + SBC_ERR_NOMEM, /**< Memory allocation error **/ + SBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/ + SBC_ERR_BADFILE, /**< A bad file was supplied **/ + SBC_ERR_NO_SUCH_SERVICE, /**< There is no such service provided **/ + SBC_ERR_IO_FAILURE, /**< There was an IO error **/ + SBC_ERR_CAN_NOT_COMPLETE,/**< Can not complete action **/ + SBC_ERR_NO_MORE_ITEMS, /**< No more items left **/ + SBC_ERR_FILE_EXISTS, /**< File already exists **/ + SBC_ERR_ACCESS_DENIED, /**< Access has been denied **/ +}; + +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; /* the change sequence number */ @@ -27,75 +60,428 @@ struct smbconf_csn { uint64_t csn; }; +/** Information about a service */ struct smbconf_service { - char *name; - uint32_t num_params; - char **param_names; - char **param_values; + char *name; /**< The name of the share */ + uint32_t num_params; /**< List of length num_shares of parameter counts for each share */ + char **param_names; /**< List of lists of parameter names for each share */ + char **param_values; /**< List of lists of parameter values for each share */ }; /* - * the smbconf API functions + * The smbconf API functions + */ + +/** + * @brief Translate an error value into a string + * + * @param error + * + * @return a pointer to a static string + **/ +const char *sbcErrorString(sbcErr error); + +/** + * @brief Check if the backend requires messaging to be set up. + * + * Tell whether the backend requires messaging to be set up + * for the backend to work correctly. + * + * @param[in] ctx The smbconf context to check. + * + * @return True if needed, false if not. */ bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx); + +/** + * @brief Tell whether the source is writeable. + * + * @param[in] ctx The smbconf context to check. + * + * @return True if it is writeable, false if not. + */ bool smbconf_is_writeable(struct smbconf_ctx *ctx); + +/** + * @brief Close the configuration. + * + * @param[in] ctx The smbconf context to close. + */ void smbconf_shutdown(struct smbconf_ctx *ctx); + +/** + * @brief Detect changes in the configuration. + * + * Get the change sequence number of the given service/parameter. Service and + * parameter strings may be NULL. + * + * The given change sequence number (csn) struct is filled with the current + * csn. smbconf_changed() can also be used for initial retrieval of the csn. + * + * @param[in] ctx The smbconf context to check for changes. + * + * @param[inout] csn The smbconf csn to be filled. + * + * @param[in] service The service name to check or NULL. + * + * @param[in] param The param to check or NULL. + * + * @return True if it has been changed, false if not. + */ bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn, const char *service, const char *param); -WERROR smbconf_drop(struct smbconf_ctx *ctx); -WERROR smbconf_get_config(struct smbconf_ctx *ctx, + +/** + * @brief Drop the whole configuration (restarting empty). + * + * @param[in] ctx The smbconf context to drop the config. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_drop(struct smbconf_ctx *ctx); + +/** + * @brief Get the whole configuration as lists of strings with counts. + * + * @param[in] ctx The smbconf context to get the lists from. + * + * @param[in] mem_ctx The memory context to use. + * + * @param[in] num_shares A pointer to store the number of shares. + * + * @param[out] services A pointer to store the services. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + * + * @see smbconf_service + */ +sbcErr smbconf_get_config(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_shares, struct smbconf_service ***services); -WERROR smbconf_get_share_names(struct smbconf_ctx *ctx, + +/** + * @brief Get the list of share names defined in the configuration. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx The memory context to use. + * + * @param[in] num_shares A pointer to store the number of shares. + * + * @param[in] share_names A pointer to store the share names. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names); + +/** + * @brief Check if a share/service of a given name exists. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] servicename The service name to check if it exists. + * + * @return True if it exists, false if not. + */ bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename); -WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename); -WERROR smbconf_get_share(struct smbconf_ctx *ctx, + +/** + * @brief Add a service if it does not already exist. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] servicename The name of the service to add. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename); + +/** + * @brief Get a definition of a share (service) from configuration. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx A memory context to allocate the result. + * + * @param[in] servicename The service name to get the information from. + * + * @param[out] service A pointer to store the service information about the + * share. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + * + * @see smbconf_service + */ +sbcErr smbconf_get_share(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *servicename, struct smbconf_service **service); -WERROR smbconf_delete_share(struct smbconf_ctx *ctx, + +/** + * @brief Delete a service from configuration. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] servicename The service name to delete. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename); -WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, + +/** + * @brief Set a configuration parameter to the value provided. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] service The service name to set the parameter. + * + * @param[in] param The name of the parameter to set. + * + * @param[in] valstr The value to set. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx, const char *service, const char *param, const char *valstr); -WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx, + +/** + * @brief Set a global configuration parameter to the value provided. + * + * This adds a paramet in the [global] service. It also creates [global] if it + * does't exist. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] param The name of the parameter to set. + * + * @param[in] val The value to set. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, const char *param, const char *val); -WERROR smbconf_get_parameter(struct smbconf_ctx *ctx, + +/** + * @brief Get the value of a configuration parameter as a string. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx The memory context to allocate the string on. + * + * @param[in] service The name of the service where to find the parameter. + * + * @param[in] param The parameter to get. + * + * @param[out] valstr A pointer to store the value as a string. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +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, + +/** + * @brief Get the value of a global configuration parameter as a string. + * + * It also creates [global] if it does't exist. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx The memory context to allocate the string on. + * + * @param[in] param The parameter to get. + * + * @param[out] valstr A pointer to store the value as a string. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *param, char **valstr); -WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, + +/** + * @brief Delete a parameter from the configuration. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] service The service where the parameter can be found. + * + * @param[in] param The name of the parameter to delete. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param); -WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, + +/** + * @brief Delete a global parameter from the configuration. + * + * It also creates [global] if it does't exist. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] param The name of the parameter to delete. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, const char *param); -WERROR smbconf_get_includes(struct smbconf_ctx *ctx, + +/** + * @brief Get the list of names of included files. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx The memory context to allocate the names. + * + * @param[in] service The service name to get the include files. + * + * @param[out] num_includes A pointer to store the number of included files. + * + * @param[out] includes A pointer to store the paths of the included files. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_get_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, uint32_t *num_includes, char ***includes); -WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx, + +/** + * @brief Get the list of globally included files. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] mem_ctx The memory context to allocate the names. + * + * @param[out] num_includes A pointer to store the number of included files. + * + * @param[out] includes A pointer to store the paths of the included files. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_includes, char ***includes); -WERROR smbconf_set_includes(struct smbconf_ctx *ctx, + +/** + * @brief Set a list of config files to include on the given service. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] service The service to add includes. + * + * @param[in] num_includes The number of includes to set. + * + * @param[in] includes A list of paths to include. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_set_includes(struct smbconf_ctx *ctx, const char *service, uint32_t num_includes, const char **includes); -WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx, + +/** + * @brief Set a list of config files to include globally. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] num_includes The number of includes to set. + * + * @param[in] includes A list of paths to include. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx, uint32_t num_includes, const char **includes); -WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service); -WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx); -WERROR smbconf_transaction_start(struct smbconf_ctx *ctx); -WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx); -WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx); +/** + * @brief Delete include parameter on the given service. + * + * @param[in] ctx The smbconf context to use. + * + * @param[in] service The name of the service to delete the includes from. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service); + +/** + * @brief Delete include parameter from the global service. + * + * @param[in] ctx The smbconf context to use. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_delete_global_includes(struct smbconf_ctx *ctx); + +/** + * @brief Start a transaction on the configuration backend. + * + * This is to speed up writes to the registry based backend. + * + * @param[in] ctx The smbconf context to start the transaction. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + */ +sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx); + +/** + * @brief Commit a transaction on the configuration backend. + * + * This is to speed up writes to the registry based backend. + * + * @param[in] ctx The smbconf context to commit the transaction. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + * + * @see smbconf_transaction_start() + */ +sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx); + +/** + * @brief Cancel a transaction on the configuration backend. + * + * @param[in] ctx The smbconf context to cancel the transaction. + * + * @return SBC_ERR_OK on success, a corresponding sbcErr if an + * error occured. + * + * @see smbconf_transaction_start() + */ +sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx); + +/* @} ******************************************************************/ #endif /* _LIBSMBCONF_H_ */ diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h index e6998ad639..e768c30b91 100644 --- a/lib/smbconf/smbconf_private.h +++ b/lib/smbconf/smbconf_private.h @@ -27,50 +27,50 @@ #include "lib/smbconf/smbconf.h" struct smbconf_ops { - WERROR (*init)(struct smbconf_ctx *ctx, const char *path); + sbcErr (*init)(struct smbconf_ctx *ctx, const char *path); int (*shutdown)(struct smbconf_ctx *ctx); bool (*requires_messaging)(struct smbconf_ctx *ctx); bool (*is_writeable)(struct smbconf_ctx *ctx); - WERROR (*open_conf)(struct smbconf_ctx *ctx); + sbcErr (*open_conf)(struct smbconf_ctx *ctx); int (*close_conf)(struct smbconf_ctx *ctx); void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn, const char *service, const char *param); - WERROR (*drop)(struct smbconf_ctx *ctx); - WERROR (*get_share_names)(struct smbconf_ctx *ctx, + sbcErr (*drop)(struct smbconf_ctx *ctx); + sbcErr (*get_share_names)(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names); bool (*share_exists)(struct smbconf_ctx *ctx, const char *service); - WERROR (*create_share)(struct smbconf_ctx *ctx, const char *service); - WERROR (*get_share)(struct smbconf_ctx *ctx, + sbcErr (*create_share)(struct smbconf_ctx *ctx, const char *service); + sbcErr (*get_share)(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *servicename, struct smbconf_service **service); - WERROR (*delete_share)(struct smbconf_ctx *ctx, + sbcErr (*delete_share)(struct smbconf_ctx *ctx, const char *servicename); - WERROR (*set_parameter)(struct smbconf_ctx *ctx, + sbcErr (*set_parameter)(struct smbconf_ctx *ctx, 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, char **valstr); - WERROR (*delete_parameter)(struct smbconf_ctx *ctx, + sbcErr (*delete_parameter)(struct smbconf_ctx *ctx, const char *service, const char *param); - WERROR (*get_includes)(struct smbconf_ctx *ctx, + sbcErr (*get_includes)(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, uint32_t *num_includes, char ***includes); - WERROR (*set_includes)(struct smbconf_ctx *ctx, + sbcErr (*set_includes)(struct smbconf_ctx *ctx, const char *service, uint32_t num_includes, const char **includes); - WERROR (*delete_includes)(struct smbconf_ctx *ctx, + sbcErr (*delete_includes)(struct smbconf_ctx *ctx, const char *service); - WERROR (*transaction_start)(struct smbconf_ctx *ctx); - WERROR (*transaction_commit)(struct smbconf_ctx *ctx); - WERROR (*transaction_cancel)(struct smbconf_ctx *ctx); + sbcErr (*transaction_start)(struct smbconf_ctx *ctx); + sbcErr (*transaction_commit)(struct smbconf_ctx *ctx); + sbcErr (*transaction_cancel)(struct smbconf_ctx *ctx); }; struct smbconf_ctx { @@ -79,10 +79,10 @@ struct smbconf_ctx { void *data; /* private data for use in backends */ }; -WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, +sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, const char *path, struct smbconf_ops *ops); -WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, +sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, char ***array, uint32_t count, const char *string); diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c index 2114841b81..5c4bd27b9d 100644 --- a/lib/smbconf/smbconf_txt.c +++ b/lib/smbconf/smbconf_txt.c @@ -60,7 +60,7 @@ static struct txt_private_data *pd(struct smbconf_ctx *ctx) static bool smbconf_txt_do_section(const char *section, void *private_data) { - WERROR werr; + sbcErr err; uint32_t idx; struct txt_private_data *tpd = (struct txt_private_data *)private_data; struct txt_cache *cache = tpd->cache; @@ -72,9 +72,9 @@ static bool smbconf_txt_do_section(const char *section, void *private_data) return true; } - werr = smbconf_add_string_to_array(cache, &(cache->share_names), - cache->num_shares, section); - if (!W_ERROR_IS_OK(werr)) { + err = smbconf_add_string_to_array(cache, &(cache->share_names), + cache->num_shares, section); + if (!SBC_ERROR_IS_OK(err)) { return false; } cache->current_share = cache->num_shares; @@ -114,7 +114,7 @@ static bool smbconf_txt_do_parameter(const char *param_name, const char *param_value, void *private_data) { - WERROR werr; + sbcErr err; char **param_names, **param_values; uint32_t num_params; uint32_t idx; @@ -146,17 +146,17 @@ static bool smbconf_txt_do_parameter(const char *param_name, } return true; } - werr = smbconf_add_string_to_array(cache, + err = smbconf_add_string_to_array(cache, &(cache->param_names[cache->current_share]), num_params, param_name); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { return false; } - werr = smbconf_add_string_to_array(cache, + err = smbconf_add_string_to_array(cache, &(cache->param_values[cache->current_share]), num_params, param_value); cache->num_params[cache->current_share]++; - return W_ERROR_IS_OK(werr); + return SBC_ERROR_IS_OK(err); } static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx) @@ -165,7 +165,7 @@ static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx) pd(ctx)->cache = NULL; } -static WERROR smbconf_txt_init_cache(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_init_cache(struct smbconf_ctx *ctx) { if (pd(ctx)->cache != NULL) { smbconf_txt_flush_cache(ctx); @@ -174,40 +174,40 @@ static WERROR smbconf_txt_init_cache(struct smbconf_ctx *ctx) pd(ctx)->cache = talloc_zero(pd(ctx), struct txt_cache); if (pd(ctx)->cache == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } - return WERR_OK; + return SBC_ERR_OK; } -static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx) { - WERROR werr; + sbcErr err; uint64_t new_csn; if (!file_exist(ctx->path)) { - return WERR_BADFILE; + return SBC_ERR_BADFILE; } new_csn = (uint64_t)file_modtime(ctx->path); if (new_csn == pd(ctx)->csn) { - return WERR_OK; + return SBC_ERR_OK; } - werr = smbconf_txt_init_cache(ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_txt_init_cache(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } if (!pm_process(ctx->path, smbconf_txt_do_section, smbconf_txt_do_parameter, pd(ctx))) { - return WERR_CAN_NOT_COMPLETE; + return SBC_ERR_CAN_NOT_COMPLETE; } pd(ctx)->csn = new_csn; - return WERR_OK; + return SBC_ERR_OK; } @@ -220,24 +220,24 @@ static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx) /** * initialize the text based smbconf backend */ -static WERROR smbconf_txt_init(struct smbconf_ctx *ctx, const char *path) +static sbcErr smbconf_txt_init(struct smbconf_ctx *ctx, const char *path) { if (path == NULL) { - return WERR_BADFILE; + return SBC_ERR_BADFILE; } ctx->path = talloc_strdup(ctx, path); if (ctx->path == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } ctx->data = talloc_zero(ctx, struct txt_private_data); if (ctx->data == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } pd(ctx)->verbatim = true; - return WERR_OK; + return SBC_ERR_OK; } static int smbconf_txt_shutdown(struct smbconf_ctx *ctx) @@ -256,7 +256,7 @@ static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx) return false; } -static WERROR smbconf_txt_open(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_open(struct smbconf_ctx *ctx) { return smbconf_txt_load_file(ctx); } @@ -285,15 +285,15 @@ static void smbconf_txt_get_csn(struct smbconf_ctx *ctx, /** * Drop the whole configuration (restarting empty) */ -static WERROR smbconf_txt_drop(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_drop(struct smbconf_ctx *ctx) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } /** * get the list of share names defined in the configuration. */ -static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_get_share_names(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names) @@ -301,17 +301,16 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx, uint32_t count; uint32_t added_count = 0; TALLOC_CTX *tmp_ctx = NULL; - WERROR werr = WERR_OK; + sbcErr err = SBC_ERR_OK; char **tmp_share_names = NULL; if ((num_shares == NULL) || (share_names == NULL)) { - werr = WERR_INVALID_PARAM; - goto done; + return SBC_ERR_INVALID_PARAM; } - werr = smbconf_txt_load_file(ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_txt_load_file(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } tmp_ctx = talloc_stackframe(); @@ -320,18 +319,18 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx, * possibly after NULL section */ if (smbconf_share_exists(ctx, NULL)) { - werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, - 0, NULL); - if (!W_ERROR_IS_OK(werr)) { + err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, + 0, NULL); + if (!SBC_ERROR_IS_OK(err)) { goto done; } added_count++; } if (smbconf_share_exists(ctx, GLOBAL_NAME)) { - werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, + err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, added_count, GLOBAL_NAME); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { goto done; } added_count++; @@ -344,10 +343,10 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx, continue; } - werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, + err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, added_count, pd(ctx)->cache->share_names[count]); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { goto done; } added_count++; @@ -362,7 +361,7 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx, done: talloc_free(tmp_ctx); - return werr; + return err; } /** @@ -371,10 +370,10 @@ done: static bool smbconf_txt_share_exists(struct smbconf_ctx *ctx, const char *servicename) { - WERROR werr; + sbcErr err; - werr = smbconf_txt_load_file(ctx); - if (!W_ERROR_IS_OK(werr)) { + err = smbconf_txt_load_file(ctx); + if (!SBC_ERROR_IS_OK(err)) { return false; } @@ -386,29 +385,29 @@ static bool smbconf_txt_share_exists(struct smbconf_ctx *ctx, /** * Add a service if it does not already exist */ -static WERROR smbconf_txt_create_share(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx, const char *servicename) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } /** * get a definition of a share (service) from configuration. */ -static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_get_share(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *servicename, struct smbconf_service **service) { - WERROR werr; + sbcErr err; uint32_t sidx, count; bool found; TALLOC_CTX *tmp_ctx = NULL; struct smbconf_service *tmp_service = NULL; - werr = smbconf_txt_load_file(ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_txt_load_file(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } found = smbconf_find_in_array(servicename, @@ -416,38 +415,38 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx, pd(ctx)->cache->num_shares, &sidx); if (!found) { - return WERR_NO_SUCH_SERVICE; + return SBC_ERR_NO_SUCH_SERVICE; } tmp_ctx = talloc_stackframe(); tmp_service = talloc_zero(tmp_ctx, struct smbconf_service); if (tmp_service == NULL) { - werr = WERR_NOMEM; + err = SBC_ERR_NOMEM; goto done; } if (servicename != NULL) { tmp_service->name = talloc_strdup(tmp_service, servicename); if (tmp_service->name == NULL) { - werr = WERR_NOMEM; + err = SBC_ERR_NOMEM; goto done; } } for (count = 0; count < pd(ctx)->cache->num_params[sidx]; count++) { - werr = smbconf_add_string_to_array(tmp_service, + err = smbconf_add_string_to_array(tmp_service, &(tmp_service->param_names), count, pd(ctx)->cache->param_names[sidx][count]); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { goto done; } - werr = smbconf_add_string_to_array(tmp_service, + err = smbconf_add_string_to_array(tmp_service, &(tmp_service->param_values), count, pd(ctx)->cache->param_values[sidx][count]); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { goto done; } } @@ -457,45 +456,45 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx, done: talloc_free(tmp_ctx); - return werr; + return err; } /** * delete a service from configuration */ -static WERROR smbconf_txt_delete_share(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx, const char *servicename) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } /** * set a configuration parameter to the value provided. */ -static WERROR smbconf_txt_set_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx, const char *service, const char *param, const char *valstr) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } /** * 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, char **valstr) { - WERROR werr; + sbcErr err; bool found; uint32_t share_index, param_index; - werr = smbconf_txt_load_file(ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_txt_load_file(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } found = smbconf_find_in_array(service, @@ -503,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, @@ -511,45 +510,45 @@ 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; } /** * delete a parameter from configuration */ -static WERROR smbconf_txt_delete_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } -static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_get_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *service, uint32_t *num_includes, char ***includes) { - WERROR werr; + sbcErr err; bool found; uint32_t sidx, count; TALLOC_CTX *tmp_ctx = NULL; uint32_t tmp_num_includes = 0; char **tmp_includes = NULL; - werr = smbconf_txt_load_file(ctx); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_txt_load_file(ctx); + if (!SBC_ERROR_IS_OK(err)) { + return err; } found = smbconf_find_in_array(service, @@ -557,7 +556,7 @@ static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx, pd(ctx)->cache->num_shares, &sidx); if (!found) { - return WERR_NO_SUCH_SERVICE; + return SBC_ERR_NO_SUCH_SERVICE; } tmp_ctx = talloc_stackframe(); @@ -566,11 +565,11 @@ static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx, if (strequal(pd(ctx)->cache->param_names[sidx][count], "include")) { - werr = smbconf_add_string_to_array(tmp_ctx, + err = smbconf_add_string_to_array(tmp_ctx, &tmp_includes, tmp_num_includes, pd(ctx)->cache->param_values[sidx][count]); - if (!W_ERROR_IS_OK(werr)) { + if (!SBC_ERROR_IS_OK(err)) { goto done; } tmp_num_includes++; @@ -581,47 +580,47 @@ static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx, if (*num_includes > 0) { *includes = talloc_move(mem_ctx, &tmp_includes); if (*includes == NULL) { - werr = WERR_NOMEM; + err = SBC_ERR_NOMEM; goto done; } } else { *includes = NULL; } - werr = WERR_OK; + err = SBC_ERR_OK; done: talloc_free(tmp_ctx); - return werr; + return err; } -static WERROR smbconf_txt_set_includes(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_set_includes(struct smbconf_ctx *ctx, const char *service, uint32_t num_includes, const char **includes) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } -static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_delete_includes(struct smbconf_ctx *ctx, const char *service) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } -static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_transaction_start(struct smbconf_ctx *ctx) { - return WERR_OK; + return SBC_ERR_OK; } -static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_transaction_commit(struct smbconf_ctx *ctx) { - return WERR_OK; + return SBC_ERR_OK; } -static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx) +static sbcErr smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx) { - return WERR_OK; + return SBC_ERR_OK; } static struct smbconf_ops smbconf_ops_txt = { @@ -654,15 +653,15 @@ static struct smbconf_ops smbconf_ops_txt = { * initialize the smbconf text backend * the only function that is exported from this module */ -WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx, +sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, const char *path) { - WERROR werr; + sbcErr err; - werr = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt); - if (!W_ERROR_IS_OK(werr)) { - return werr; + err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt); + if (!SBC_ERROR_IS_OK(err)) { + return err; } return smbconf_txt_load_file(*conf_ctx); diff --git a/lib/smbconf/smbconf_txt.h b/lib/smbconf/smbconf_txt.h index 688bbc9d48..72d6207521 100644 --- a/lib/smbconf/smbconf_txt.h +++ b/lib/smbconf/smbconf_txt.h @@ -26,7 +26,7 @@ struct smbconf_ctx; * initialization functions for the text/file backend modules */ -WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx, +sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, const char *path); diff --git a/lib/smbconf/smbconf_util.c b/lib/smbconf/smbconf_util.c index b309a3454b..86a95988f1 100644 --- a/lib/smbconf/smbconf_util.c +++ b/lib/smbconf/smbconf_util.c @@ -39,43 +39,43 @@ static int smbconf_destroy_ctx(struct smbconf_ctx *ctx) * After the work with the configuration is completed, smbconf_shutdown() * should be called. */ -WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, +sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, const char *path, struct smbconf_ops *ops) { - WERROR werr = WERR_OK; + sbcErr err = SBC_ERR_OK; struct smbconf_ctx *ctx; if (conf_ctx == NULL) { - return WERR_INVALID_PARAM; + return SBC_ERR_INVALID_PARAM; } ctx = talloc_zero(mem_ctx, struct smbconf_ctx); if (ctx == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } ctx->ops = ops; - werr = ctx->ops->init(ctx, path); - if (!W_ERROR_IS_OK(werr)) { + err = ctx->ops->init(ctx, path); + if (!SBC_ERROR_IS_OK(err)) { goto fail; } talloc_set_destructor(ctx, smbconf_destroy_ctx); *conf_ctx = ctx; - return werr; + return err; fail: talloc_free(ctx); - return werr; + return err; } /** * add a string to a talloced array of strings. */ -WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, +sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, char ***array, uint32_t count, const char *string) @@ -83,12 +83,12 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, char **new_array = NULL; if (array == NULL) { - return WERR_INVALID_PARAM; + return SBC_ERR_INVALID_PARAM; } new_array = talloc_realloc(mem_ctx, *array, char *, count + 1); if (new_array == NULL) { - return WERR_NOMEM; + return SBC_ERR_NOMEM; } if (string == NULL) { @@ -97,13 +97,13 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, new_array[count] = talloc_strdup(new_array, string); if (new_array[count] == NULL) { talloc_free(new_array); - return WERR_NOMEM; + return SBC_ERR_NOMEM; } } *array = new_array; - return WERR_OK; + return SBC_ERR_OK; } bool smbconf_find_in_array(const char *string, char **list, |