summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-12-18 02:47:01 +0100
committerGünther Deschner <gd@samba.org>2007-12-21 15:29:10 +0100
commitfb2c13fe191212f5e782b398fa4dffa42bfba129 (patch)
tree361567d3fe073b2a79a68d3238e044e5c0954ab2 /source3/lib/netapi
parentd14ee1dc08c5c765b07bd472e47e34152db2f9d3 (diff)
downloadsamba-fb2c13fe191212f5e782b398fa4dffa42bfba129.tar.gz
samba-fb2c13fe191212f5e782b398fa4dffa42bfba129.tar.bz2
samba-fb2c13fe191212f5e782b398fa4dffa42bfba129.zip
Add static libnetapi_ctx.
Guenther (This used to be commit 97449ea341539a709953a57869570cf13be0f44e)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r--source3/lib/netapi/netapi.c28
-rw-r--r--source3/lib/netapi/netapi.h1
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);