import "ecere" static const char * indexNames[] = { "index.html", "index.htm", "home.html", "home.htm", "welcome.html", "welcome.htm", "default.html", "default.htm" }; #define NUM_INDEX (sizeof(indexNames) / sizeof(char *)) static void WriteFileName(File f, const char * fileName) { byte ch; int c; for(c = 0; (ch = fileName[c]); c++) { if(ch <= 32 || ch > 128) { byte nibble; f.Putc('%'); nibble = (ch & 0xF0) >> 4; f.Putc((char)((nibble > 9) ? (nibble - 10 + 'a') : (nibble + '0'))); nibble = ch & 0x0F; f.Putc((char)((nibble > 9) ? (nibble - 10 + 'a') : (nibble + '0'))); } else f.Putc(ch); } } #define CONTENT_PATH "." static void CreateDirectoryListing(File f, char * directory) { FileListing listing { directory }; f.Puts("\r\n"); if(directory[0] && directory[1] && (directory[1] != ':' || (directory[2] && directory[3]))) f.Puts("../
\r\n"); while(listing.Find()) { f.Puts(""); f.Puts(listing.name); f.Puts("
\r\n"); } f.Puts("\r\n\r\n"); } static const char * GetString(const char * string, const char * what, int count) { int c; bool result = true; for(c = 0; what[c]; c++) { if((count && c >= count) || (string[c] != what[c] && tolower(string[c]) != tolower(what[c]))) return null; } return string + c; } class HTTPClient : Socket { File f; bool close; #define ishexdigit(x) (isdigit(x) || (x >= 'a' && x<='f') || (x >= 'A' && x <= 'F')) uint OnReceive(const byte * buffer, uint count) { int c; for(c = 0; c 0 && string[d] != ' '; d--); for(i = 0; i