summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-05-21 19:53:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:44 -0500
commitfb1078dd1848220957815250aca195aaba85c614 (patch)
tree9ceab09cff982ddd998fbda4a40fc6b5f8ce67d3 /source4/scripting/ejs
parent6eaf8ee84960c85b703403a8c5ca440e330b0b80 (diff)
downloadsamba-fb1078dd1848220957815250aca195aaba85c614.tar.gz
samba-fb1078dd1848220957815250aca195aaba85c614.tar.bz2
samba-fb1078dd1848220957815250aca195aaba85c614.zip
r23047: Allow local inclusion of js files as well as from predefined
path(s). rafal (This used to be commit 278d26576a625d0fa161f492b902074ea82ef1a8)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/smbcalls.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 24f48f8b76..9a4a9f9624 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -120,17 +120,34 @@ static int ejs_libinclude(int eid, int argc, char **argv)
for (i = 0; i < argc; i++) {
const char *script = argv[i];
+ struct MprVar result;
+ char *path, *emsg;
+ int ret;
+ /* First, try to include file from current working directory.
+ This allows local includes which is handy sometimes. */
+ path = talloc_asprintf(mprMemCtx(), "%s", script);
+ if (path == NULL) {
+ return -1;
+ }
+
+ if (file_exist(path)) {
+ ret = ejsEvalFile(eid, path, &result, &emsg);
+ talloc_free(path);
+ if (ret < 0) {
+ ejsSetErrorMsg(eid, "%s: %s", script, emsg);
+ return -1;
+ }
+ continue;
+ }
+
+ /* use specfied path to search for requested file */
for (j=0;js_include[j];j++) {
- char *path;
path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script);
if (path == NULL) {
return -1;
}
if (file_exist(path)) {
- int ret;
- struct MprVar result;
- char *emsg;
ret = ejsEvalFile(eid, path, &result, &emsg);
talloc_free(path);
@@ -142,6 +159,7 @@ static int ejs_libinclude(int eid, int argc, char **argv)
}
talloc_free(path);
}
+
if (js_include[j] == NULL) {
ejsSetErrorMsg(eid, "unable to include '%s'", script);
return -1;