mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
r23047: Allow local inclusion of js files as well as from predefined
path(s).
rafal
(This used to be commit 278d26576a
)
This commit is contained in:
parent
6eaf8ee849
commit
fb1078dd18
@ -120,17 +120,34 @@ static int ejs_libinclude(int eid, int argc, char **argv)
|
|||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
const char *script = argv[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++) {
|
for (j=0;js_include[j];j++) {
|
||||||
char *path;
|
|
||||||
path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script);
|
path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (file_exist(path)) {
|
if (file_exist(path)) {
|
||||||
int ret;
|
|
||||||
struct MprVar result;
|
|
||||||
char *emsg;
|
|
||||||
|
|
||||||
ret = ejsEvalFile(eid, path, &result, &emsg);
|
ret = ejsEvalFile(eid, path, &result, &emsg);
|
||||||
talloc_free(path);
|
talloc_free(path);
|
||||||
@ -142,6 +159,7 @@ static int ejs_libinclude(int eid, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
talloc_free(path);
|
talloc_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (js_include[j] == NULL) {
|
if (js_include[j] == NULL) {
|
||||||
ejsSetErrorMsg(eid, "unable to include '%s'", script);
|
ejsSetErrorMsg(eid, "unable to include '%s'", script);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user