From bbb826bdac54e3fec3426fe6d8e23790abbbc44f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 01:37:42 +0200 Subject: Add convenience function for getting at event context from ejs code. (This used to be commit b659e83cd6b627dd0ae04064bccff7220a5bd1ce) --- source4/lib/appweb/mpr/miniMpr.c | 6 ++++++ source4/lib/appweb/mpr/miniMpr.h | 2 ++ source4/scripting/ejs/ejsnet/net_ctx.c | 2 +- source4/scripting/ejs/smbcalls_auth.c | 2 +- source4/scripting/ejs/smbcalls_nbt.c | 2 +- source4/scripting/ejs/smbcalls_rpc.c | 4 ++-- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source4/lib/appweb/mpr/miniMpr.c b/source4/lib/appweb/mpr/miniMpr.c index 52b23608aa..381815eb23 100644 --- a/source4/lib/appweb/mpr/miniMpr.c +++ b/source4/lib/appweb/mpr/miniMpr.c @@ -31,6 +31,7 @@ #include "miniMpr.h" #include "param/param.h" +#include "lib/events/events.h" /************************************ Code ************************************/ #if !BLD_APPWEB @@ -50,6 +51,11 @@ void *mprMemCtx(void) return mpr_ctx; } +struct event_context *mprEventCtx(void) +{ + return event_context_find(mprMemCtx()); +} + /* return the loadparm context being used for all ejs variables */ struct loadparm_context *mprLpCtx(void) { diff --git a/source4/lib/appweb/mpr/miniMpr.h b/source4/lib/appweb/mpr/miniMpr.h index 15ce30c8df..2b8ff0af6a 100644 --- a/source4/lib/appweb/mpr/miniMpr.h +++ b/source4/lib/appweb/mpr/miniMpr.h @@ -274,6 +274,8 @@ extern void mprSetCtx(void *ctx); extern void *mprMemCtx(void); struct loadparm_context; extern struct loadparm_context *mprLpCtx(void); +struct event_context; +extern struct event_context *mprEventCtx(void); /* This function needs to be provided by anyone using ejs */ void ejs_exception(const char *reason); diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c index 99be1c4ef8..cbe163552e 100644 --- a/source4/scripting/ejs/ejsnet/net_ctx.c +++ b/source4/scripting/ejs/ejsnet/net_ctx.c @@ -50,7 +50,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv) ejsSetErrorMsg(eid, "talloc_new() failed"); return -1; } - ev = event_context_find(event_mem_ctx); + ev = mprEventCtx(); ctx = libnet_context_init(ev, mprLpCtx()); /* IF we generated a new event context, it will be under here, diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c index 908a009159..8e464a5021 100644 --- a/source4/scripting/ejs/smbcalls_auth.c +++ b/source4/scripting/ejs/smbcalls_auth.c @@ -55,7 +55,7 @@ static int ejs_doauth(MprVarHandle eid, msg = c->msg_ctx; } else { /* Hope we can find the event context somewhere up there... */ - ev = event_context_find(tmp_ctx); + ev = mprEventCtx(); msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, mprLpCtx()), lp_iconv_convenience(mprLpCtx()), ev); } diff --git a/source4/scripting/ejs/smbcalls_nbt.c b/source4/scripting/ejs/smbcalls_nbt.c index 67a85414ca..8c555bf821 100644 --- a/source4/scripting/ejs/smbcalls_nbt.c +++ b/source4/scripting/ejs/smbcalls_nbt.c @@ -70,7 +70,7 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) result = 0; - nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx)); + nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, mprEventCtx()); if (NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(argv[0], "value", mprString(reply_addr)); diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c index d1e49b4348..94774d708b 100644 --- a/source4/scripting/ejs/smbcalls_rpc.c +++ b/source4/scripting/ejs/smbcalls_rpc.c @@ -73,7 +73,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv) p->server_name = argv[0]; - ev = event_context_find(p); + ev = mprEventCtx(); /* create a messaging context, looping as we have no way to allocate temporary server ids automatically */ @@ -158,7 +158,7 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv) cli_credentials_set_anonymous(creds); } - ev = event_context_find(mprMemCtx()); + ev = mprEventCtx(); status = dcerpc_pipe_connect(this, &p, binding, iface, creds, ev, mprLpCtx()); -- cgit