From ec4bdc172e915313056e2b0ea7352adcc16b0116 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 May 2005 06:07:23 +0000 Subject: 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) --- source4/web_server/esp/espProcs.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source4/web_server') 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); } -- cgit