diff options
Diffstat (limited to 'source4/scripting/ejs/smbscript.c')
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 57f42688d6..593d3b0cf5 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "lib/ejs/ejs.h" void ejs_exception(const char *reason) @@ -29,36 +30,36 @@ void ejs_exception(const char *reason) exit(1); } -static int writeProc(MprVarHandle userHandle, int argc, char **argv) -{ - int i; - - mprAssert(argv); - for (i = 0; i < argc; i++) { - printf("%s", argv[i]); - } - return 0; -} - int main(int argc, const char *argv[]) { EjsId eid; EjsHandle handle; MprVar result; char *emsg; + TALLOC_CTX *mem_ctx = talloc_new(NULL); if (argc != 2) { fprintf(stderr, "Usage: %s <scriptfile>\n", argv[0]); exit(1); } + setup_logging(argv[0],DEBUG_STDOUT); + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", + argv[0], dyn_CONFIGFILE); + exit(1); + } + + mprSetCtx(mem_ctx); + if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); exit(1); } - ejsDefineStringCFunction(-1, "write", writeProc, NULL, 0); + smb_setup_ejs_functions(); if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " @@ -74,5 +75,7 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) ejsClose(); + talloc_free(mem_ctx); + return 0; } |