summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
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);