1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

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)
This commit is contained in:
Andrew Tridgell 2005-05-26 03:22:38 +00:00 committed by Gerald (Jerry) Carter
parent 98046f0372
commit 74dda39226
5 changed files with 26 additions and 2 deletions

View File

@ -22,6 +22,7 @@ installdir . html
installdir esptest html
installdir images png
installdir scripting ejs
installdir scripting esp
cat << EOF
======================================================================

View 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);

View 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
};

View 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>

6
swat/scripting/test.esp Normal file
View File

@ -0,0 +1,6 @@
<h3>A esp include file</h3>
<%
function testfn(test) {
return "the argument was " + test;
}
%>