installdir esptest html
installdir images png
installdir scripting ejs
+installdir scripting esp
cat << EOF
======================================================================
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);
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
*/
.setHeader = http_setHeader,
.redirect = http_redirect,
.setResponseCode = http_setResponseCode,
- .readFile = http_readFile
+ .readFile = http_readFile,
+ .mapToStorage = http_mapToStorage
};
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>
--- /dev/null
+<h3>A esp include file</h3>
+<%
+ function testfn(test) {
+ return "the argument was " + test;
+ }
+%>