]> git.samba.org - ab/samba.git/.git/commitdiff
r6989: - added support for esp style includes (which include a esp file, instead...
authorAndrew Tridgell <tridge@samba.org>
Thu, 26 May 2005 03:22:38 +0000 (03:22 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:03 +0000 (13:17 -0500)
- added a test of esp style includes to the esptest html
(This used to be commit af3de9468ee5ba490c991901b7a4aa260c839876)

source4/script/installswat.sh
source4/web_server/esp/esp.h
source4/web_server/http.c
swat/esptest/include.html
swat/scripting/test.esp [new file with mode: 0644]

index 3e6e104d034891127674b9afd00e47de51783b48..3d7651d4700b0d77709b8828c9e9ff3dc1fc87b4 100644 (file)
@@ -22,6 +22,7 @@ installdir . html
 installdir esptest html
 installdir images png
 installdir scripting ejs
+installdir scripting esp
 
 cat << EOF
 ======================================================================
index 4503cacbb728d74c93f9fab019a349fb9cd861cb..5d343db96ef829e465fc2f3a845bd6cc7b701409 100644 (file)
@@ -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);
index fa038302959c15657e5775ef725a62530f972b3b..25595a8ad7b7b5a3dc0825c98f5daad4803d0aa7 100644 (file)
@@ -157,6 +157,16 @@ failed:
        return -1;
 }
 
+/*
+  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
 */
@@ -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
 };
 
 
index b488631e83687aaaee06782cd7bd1ec91b5d254b..59322cc9fa6de393ad5c97188f8745b6d24f2357 100644 (file)
@@ -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 (file)
index 0000000..614a424
--- /dev/null
@@ -0,0 +1,6 @@
+<h3>A esp include file</h3>
+<%
+       function testfn(test) {
+                return "the argument was " + test;
+       }
+%>