From fb2c13fe191212f5e782b398fa4dffa42bfba129 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 18 Dec 2007 02:47:01 +0100 Subject: Add static libnetapi_ctx. Guenther (This used to be commit 97449ea341539a709953a57869570cf13be0f44e) --- source3/lib/netapi/netapi.c | 28 +++++++++++++++++++++++++--- source3/lib/netapi/netapi.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 454d766ae9..853ac55f8a 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -22,14 +22,16 @@ extern bool AllowDebugChange; +struct libnetapi_ctx *stat_ctx = NULL; +TALLOC_CTX *frame = NULL; static bool libnetapi_initialized = false; NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) { struct libnetapi_ctx *ctx = NULL; - TALLOC_CTX *frame = NULL; - if (libnetapi_initialized) { + if (stat_ctx && libnetapi_initialized) { + *context = stat_ctx; return W_ERROR_V(WERR_OK); } @@ -65,14 +67,34 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) libnetapi_initialized = true; - *context = ctx; + *context = stat_ctx = ctx; return W_ERROR_V(WERR_OK); } +NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx) +{ + if (stat_ctx) { + *ctx = stat_ctx; + return W_ERROR_V(WERR_OK); + } + + return libnetapi_init(ctx); +} + NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) { + gfree_names(); + gfree_loadparm(); + gfree_case_tables(); + gfree_charcnv(); + gfree_interfaces(); + TALLOC_FREE(ctx); + TALLOC_FREE(frame); + + gfree_debugsyms(); + return W_ERROR_V(WERR_OK); } diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 278922224d..0b25c93d5b 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -30,6 +30,7 @@ struct libnetapi_ctx { }; NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx); +NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx); NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx); NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel); NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel); -- cgit