svn commit: samba r7063 - in
branches/SAMBA_4_0/source/scripting/ejs: .
tpot at samba.org
tpot at samba.org
Sun May 29 03:25:21 GMT 2005
Author: tpot
Date: 2005-05-29 03:25:21 +0000 (Sun, 29 May 2005)
New Revision: 7063
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7063
Log:
Do error checking on the ejs functions.
Tridge says there is a bug in defining per-engine CFunction's so move
calls to ejsDefineStringCFunction() above the ejsOpenEngine() call.
Test script now works!
Modified:
branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbscript.c 2005-05-29 00:22:34 UTC (rev 7062)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbscript.c 2005-05-29 03:25:21 UTC (rev 7063)
@@ -29,9 +29,6 @@
exit(1);
}
-extern void ejsDefineStringCFunction(EjsId eid, const char *functionName,
- MprStringCFunction fn, void *thisPtr, int flags);
-
static int writeProc(MprVarHandle userHandle, int argc, char **argv)
{
int i;
@@ -50,13 +47,26 @@
MprVar result;
char *emsg;
- ejsOpen(0, 0, 0);
- eid = ejsOpenEngine(primary, alternate);
- ejsDefineStringCFunction(eid, "write", writeProc, NULL, 0);
- ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg);
+ if (ejsOpen(0, 0, 0) != 0) {
+ fprintf(stderr, "smbscript: ejsOpen(): unable to initialise "
+ "EJ subsystem\n");
+ exit(1);
+ }
+
+ ejsDefineStringCFunction(-1, "write", writeProc, NULL, 0);
+
+ if ((eid = ejsOpenEngine(primary, alternate)) == (EjsId)-1) {
+ fprintf(stderr, "smbscript: ejsOpenEngine(): unable to "
+ "initialise an EJS engine\n");
+ exit(1);
+ }
+
+ if (ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg) == -1) {
+ fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg);
+ exit(1);
+ }
+
ejsClose();
- printf("emsg = %s\n", emsg);
-
return 0;
}
More information about the samba-cvs
mailing list