From 36ede8ae549837452bbd577e43cda8d84ee22c4b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Apr 2008 15:01:44 +0200 Subject: libsmbconf: move utility functions from main module to new smbconf_util.c Michael (This used to be commit e0f6a9d50c9b72ec33d4323d1a6c5bdf44d011e7) --- source3/lib/smbconf/smbconf.c | 88 ------------------------------------------- 1 file changed, 88 deletions(-) (limited to 'source3/lib/smbconf/smbconf.c') diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c index 4315dd990e..62c5be8294 100644 --- a/source3/lib/smbconf/smbconf.c +++ b/source3/lib/smbconf/smbconf.c @@ -27,11 +27,6 @@ * **********************************************************************/ -static int smbconf_destroy_ctx(struct smbconf_ctx *ctx) -{ - return ctx->ops->shutdown(ctx); -} - static WERROR smbconf_global_check(struct smbconf_ctx *ctx) { if (!smbconf_share_exists(ctx, GLOBAL_NAME)) { @@ -41,89 +36,6 @@ static WERROR smbconf_global_check(struct smbconf_ctx *ctx) } -/********************************************************************** - * - * helper functions exported to the backend modules - * (might go into a smbconf_util.c) - * - **********************************************************************/ - -/** - * add a string to a talloced array of strings. - */ -WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, - char ***array, - uint32_t count, - const char *string) -{ - char **new_array = NULL; - - if ((array == NULL) || (string == NULL)) { - return WERR_INVALID_PARAM; - } - - new_array = TALLOC_REALLOC_ARRAY(mem_ctx, *array, char *, count + 1); - if (new_array == NULL) { - return WERR_NOMEM; - } - - new_array[count] = talloc_strdup(new_array, string); - if (new_array[count] == NULL) { - TALLOC_FREE(new_array); - return WERR_NOMEM; - } - - *array = new_array; - - return WERR_OK; -} - -/** - * Initialize the configuration. - * - * This should be the first function in a sequence of calls to smbconf - * functions: - * - * Upon success, this creates and returns the conf context - * that should be passed around in subsequent calls to the other - * smbconf functions. - * - * After the work with the configuration is completed, smbconf_shutdown() - * should be called. - */ -WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, - const char *path, struct smbconf_ops *ops) -{ - WERROR werr = WERR_OK; - struct smbconf_ctx *ctx; - - if (conf_ctx == NULL) { - return WERR_INVALID_PARAM; - } - - ctx = TALLOC_ZERO_P(mem_ctx, struct smbconf_ctx); - if (ctx == NULL) { - return WERR_NOMEM; - } - - ctx->ops = ops; - - werr = ctx->ops->init(ctx, path); - if (!W_ERROR_IS_OK(werr)) { - goto fail; - } - - talloc_set_destructor(ctx, smbconf_destroy_ctx); - - *conf_ctx = ctx; - return werr; - -fail: - TALLOC_FREE(ctx); - return werr; -} - - /********************************************************************** * * The actual libsmbconf API functions that are exported. -- cgit