Add convenience function for getting at event context from ejs code.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 16 Apr 2008 23:37:42 +0000 (01:37 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 16 Apr 2008 23:37:42 +0000 (01:37 +0200)
source/lib/appweb/mpr/miniMpr.c
source/lib/appweb/mpr/miniMpr.h
source/scripting/ejs/ejsnet/net_ctx.c
source/scripting/ejs/smbcalls_auth.c
source/scripting/ejs/smbcalls_nbt.c
source/scripting/ejs/smbcalls_rpc.c

index 52b23608aa7e403846355e4be88c67c2b747f35b..381815eb231a9c83cdabdc73def1d6c7bbf3bcc4 100644 (file)
@@ -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)
 {
index 15ce30c8df9d52eef3d723ee41d888fe197465dc..2b8ff0af6a98c79682ec980d0b3a5573c3efcff2 100644 (file)
@@ -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);
index 99be1c4ef8e10166c19a8972c6ea82e795bedbe6..cbe163552e2653704d4abca508f56ca8f9798a5c 100644 (file)
@@ -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,
index 908a009159a09c4a0d118b3ba9401308c04d3940..8e464a50218d13912ac4c535ef5c6ad3f0938c2a 100644 (file)
@@ -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);
        }
index 67a85414caf718fbf110c6203531487688e32da2..8c555bf821ca702b4ae34caa2b68677310b13782 100644 (file)
@@ -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));
index d1e49b4348a97823eab5fc498e4ada7c17a07c3c..94774d708bbb0008a6d9ea650fe4d02e9d9e6676 100644 (file)
@@ -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());