diff --git a/Demo/Network/HtServ.HC b/Demo/Network/HtServ.HC index 71f2f4f..c7c23b6 100644 --- a/Demo/Network/HtServ.HC +++ b/Demo/Network/HtServ.HC @@ -5,8 +5,8 @@ #define PORT 80 #define BASE_DIR "/Www" -// Set to 0 if you don't want to print anything -#define SERVER_STRING "Server: HtServ ($TX+CX,"TempleOS",D="DD_OS_NAME_VERSION"$)\r\n" +// Set to NULL if you don't want to print anything +#define HTTP_SERVER_STRING "Server: HtServ ($TX+CX,"TempleOS",D="DD_OS_NAME_VERSION"$)\r\n" #define STATE_TERM 0 #define STATE_NEW 1 @@ -23,25 +23,94 @@ class CHtServSession { U8* resource; }; +// Messy global state! +U8* new_output; + +U0 StreamPrint(U8 *fmt,...) +{//Injects text into the webpage stream. Used in tags. + U8* buf = StrPrintJoin(NULL,fmt,argc,argv); + U8* old_output = new_output; + new_output = MStrPrint("%s%s", old_output, buf); + Free(buf); + Free(old_output); +} + +Bool IsDotHTM(U8 *filename) +{//Does name end in .HTM? + I64 len = StrLen(filename); + if (len >= 4 && !StrNCmp(filename + len - 4, ".HTM", 4)) + return TRUE; + else + return FALSE; +} + +U8* PreprocessHTM(U8* body) { + new_output = StrNew(""); + U8* body_ptr = body; + + while (*body_ptr) { + // Perhaps we should use something like