summaryrefslogtreecommitdiff
path: root/source4/web_server/esp/espProcs.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-30 06:07:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:14 -0500
commitec4bdc172e915313056e2b0ea7352adcc16b0116 (patch)
tree048df80c2cde202811ebbd73d367bd2bf103a2a6 /source4/web_server/esp/espProcs.c
parent89f796006f4f532457d001910c6893aa0e70d559 (diff)
downloadsamba-ec4bdc172e915313056e2b0ea7352adcc16b0116.tar.gz
samba-ec4bdc172e915313056e2b0ea7352adcc16b0116.tar.bz2
samba-ec4bdc172e915313056e2b0ea7352adcc16b0116.zip
r7086: make include() recognise the ".esp" extension and include the file as
an esp script instead of as a ejs script (This used to be commit af97ded8d4151d33767d2b98bfcc3ca9a4fedc10)
Diffstat (limited to 'source4/web_server/esp/espProcs.c')
-rw-r--r--source4/web_server/esp/espProcs.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/source4/web_server/esp/espProcs.c b/source4/web_server/esp/espProcs.c
index ff1751a7ef..28b69a8a6f 100644
--- a/source4/web_server/esp/espProcs.c
+++ b/source4/web_server/esp/espProcs.c
@@ -71,12 +71,14 @@ static int includeProc(EspRequest *ep, int argc, char **argv)
{
const Esp *esp;
char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME];
- char *emsg, *buf;
+ char *emsg=NULL, *buf;
int size, i;
esp = ep->esp;
mprAssert(argv);
for (i = 0; i < argc; i++) {
+ const char *extension;
+
if (argv[i][0] != '/') {
mprGetDirName(dir, sizeof(dir), ep->docPath);
mprSprintf(path, sizeof(path), "%s/%s", dir, argv[i]);
@@ -90,10 +92,20 @@ static int includeProc(EspRequest *ep, int argc, char **argv)
}
buf[size] = '\0';
- if (ejsEvalScript(espGetScriptHandle(ep), buf, 0, &emsg) < 0) {
- espError(ep, "Cant evaluate script");
- mprFree(buf);
- return -1;
+ extension = strrchr(argv[i], '.');
+ /* this makes handling include files in esp scripts much more convenient */
+ if (extension && strcasecmp(extension, ".esp") == 0) {
+ if (espProcessRequest(ep, path, buf, &emsg) != 0) {
+ espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
+ mprFree(buf);
+ return -1;
+ }
+ } else {
+ if (ejsEvalScript(espGetScriptHandle(ep), buf, 0, &emsg) < 0) {
+ espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
+ mprFree(buf);
+ return -1;
+ }
}
mprFree(buf);
}