mirror of
https://github.com/samba-team/samba.git
synced 2025-10-25 19:33:18 +03:00
r7072: moved the esp hooks calls to the ejs level, so we can call them from
both esp scripts and ejs scripts. This allows the smbscript program to call all the existing extension calls like lpGet() and ldbSearch() Also fixed smbscript to load smb.conf, and setup logging for DEBUG() I left the unixAuth() routine in web_server/calls.c at the moment, as that is really only useful for esp scripts. I imagine that as we extend esp/ejs, we will put some functions in scripting/ejs/ for use in both ejs and esp, and some functions in web_server/ where they will only be accessed by esp web scripts
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
a58531dcf3
commit
e59ae64f60
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user