summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-26 03:22:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:03 -0500
commit74dda392261e52e80a4ff24ea08f042e02154ed7 (patch)
treeb1779c5c8678f686834e615f8df464770d5948ee
parent98046f037200938bb2532e3c480946653a0b53bd (diff)
downloadsamba-74dda392261e52e80a4ff24ea08f042e02154ed7.tar.gz
samba-74dda392261e52e80a4ff24ea08f042e02154ed7.tar.bz2
samba-74dda392261e52e80a4ff24ea08f042e02154ed7.zip
r6989: - added support for esp style includes (which include a esp file, instead of a ejs file)
- added a test of esp style includes to the esptest html (This used to be commit af3de9468ee5ba490c991901b7a4aa260c839876)
-rw-r--r--source4/script/installswat.sh1
-rw-r--r--source4/web_server/esp/esp.h2
-rw-r--r--source4/web_server/http.c13
-rw-r--r--swat/esptest/include.html6
-rw-r--r--swat/scripting/test.esp6
5 files changed, 26 insertions, 2 deletions
diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh
index 3e6e104d03..3d7651d470 100644
--- a/source4/script/installswat.sh
+++ b/source4/script/installswat.sh
@@ -22,6 +22,7 @@ installdir . html
installdir esptest html
installdir images png
installdir scripting ejs
+installdir scripting esp
cat << EOF
======================================================================
diff --git a/source4/web_server/esp/esp.h b/source4/web_server/esp/esp.h
index 4503cacbb7..5d343db96e 100644
--- a/source4/web_server/esp/esp.h
+++ b/source4/web_server/esp/esp.h
@@ -97,7 +97,7 @@ typedef struct Esp {
void (*createSession)(EspHandle handle, int timeout);
void (*destroySession)(EspHandle handle);
char *(*getSessionId)(EspHandle handle);
- int (*mapToStorage)(EspHandle handle, char *path, int len, char *uri,
+ int (*mapToStorage)(EspHandle handle, char *path, int len, const char *uri,
int flags);
int (*readFile)(EspHandle handle, char **buf, int *len, const char *path);
void (*redirect)(EspHandle handle, int code, char *url);
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index fa03830295..25595a8ad7 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -158,6 +158,16 @@ failed:
}
/*
+ called when esp wants to find the real path of a file
+*/
+static int http_mapToStorage(EspHandle handle, char *path, int len, const char *uri, int flags)
+{
+ if (uri == NULL || strlen(uri) >= len) return -1;
+ strncpy(path, uri, len);
+ return 0;
+}
+
+/*
called when esp wants to output something
*/
static int http_writeBlock(EspHandle handle, char *buf, int size)
@@ -253,7 +263,8 @@ static const struct Esp esp_control = {
.setHeader = http_setHeader,
.redirect = http_redirect,
.setResponseCode = http_setResponseCode,
- .readFile = http_readFile
+ .readFile = http_readFile,
+ .mapToStorage = http_mapToStorage
};
diff --git a/swat/esptest/include.html b/swat/esptest/include.html
index b488631e83..59322cc9fa 100644
--- a/swat/esptest/include.html
+++ b/swat/esptest/include.html
@@ -8,6 +8,12 @@ including /scripting/test.ejs<p>
calling a function from test.ejs ...<p>
<% showArray("request", request); %>
+including /scripting/test.esp<p>
+<% include /scripting/test.esp %>
+calling a function from test.esp ...<p>
+<% res = testfn('foo'); %>
+result is: @@res
+
<form name="Cancel" method="POST" action="index.html">
<input name="submit" type="submit" value="Cancel"><br>
</form>
diff --git a/swat/scripting/test.esp b/swat/scripting/test.esp
new file mode 100644
index 0000000000..614a42410c
--- /dev/null
+++ b/swat/scripting/test.esp
@@ -0,0 +1,6 @@
+<h3>A esp include file</h3>
+<%
+ function testfn(test) {
+ return "the argument was " + test;
+ }
+%>