1 /* HTTPMISC.H (c)Copyright Jan Jaeger, 2002-2009 */ 2 /* HTTP Server header file */ 3 4 #ifndef _HTTPMISC_H 5 #define _HTTPMISC_H 6 7 8 #ifdef _HTTPSERV_C_ 9 /* We're building the 'httpserv.c' module, so export 10 our entry-points so that others may import them */ 11 #define HTTP_DLL_IMPORT DLL_EXPORT 12 #else /* _HTTPSERV_C_ */ 13 /* We're building the 'hengine.dll' module, so declare 14 our entry-points as extern so we can link ourselves */ 15 #ifdef _HENGINE_DLL_ 16 #define HTTP_DLL_IMPORT extern 17 #else /* _HENGINE_DLL_ */ 18 /* Some other module is being built, so declare our 19 entry-points as 'import' so they can import them */ 20 #define HTTP_DLL_IMPORT DLL_IMPORT 21 #endif /* _HENGINE_DLL_ */ 22 #endif /* _HTTPSERV_C_ */ 23 24 25 #if !defined(PKGDATADIR) 26 #if !defined(_MSVC_) 27 #define HTTP_ROOT "/usr/local/share/hercules/" 28 #else 29 #define HTTP_ROOT "%ProgramFiles%\\Hercules\\html\\" 30 #endif 31 #else 32 #define HTTP_ROOT PKGDATADIR "/" 33 #endif 34 35 #if !defined(_MSVC_) 36 #define HTTP_PS "/" 37 #else 38 #define HTTP_PS "\\" 39 #endif 40 41 #define HTTP_WELCOME "hercules.html" 42 43 #define HTML_HEADER "include/header.htmlpart" 44 #define HTML_FOOTER "include/footer.htmlpart" 45 46 47 #define HTML_STATIC_EXPIRY_TIME (60*60*24*7) 48 49 #if defined(PATH_MAX) 50 #define HTTP_PATH_LENGTH PATH_MAX 51 #else 52 #define HTTP_PATH_LENGTH 1024 53 #endif 54 55 typedef struct _CGIVAR { 56 struct _CGIVAR *next; 57 char *name; 58 char *value; 59 int type; 60 #define VARTYPE_NONE 0 61 #define VARTYPE_GET 1 62 #define VARTYPE_POST 2 63 #define VARTYPE_PUT 4 64 #define VARTYPE_COOKIE 8 65 } CGIVAR; 66 67 68 #define cgi_variable(_webblk, _varname) \ 69 http_variable((_webblk), (_varname), (VARTYPE_GET|VARTYPE_POST)) 70 71 72 #define cgi_cookie(_webblk, _varname) \ 73 http_variable((_webblk), (_varname), (VARTYPE_COOKIE)) 74 75 76 #define cgi_username(_webblk) \ 77 ((_webblk)->user) 78 79 80 #define cgi_baseurl(_webblk) \ 81 ((_webblk)->baseurl) 82 83 84 typedef struct _MIMETAB { 85 char *suffix; 86 char *type; 87 } MIMETAB; 88 89 90 typedef struct _WEBBLK { 91 #define HDL_VERS_WEBBLK "2.17" 92 #define HDL_SIZE_WEBBLK sizeof(WEBBLK) 93 int sock; 94 int request_type; 95 #define REQTYPE_NONE 0 96 #define REQTYPE_GET 1 97 #define REQTYPE_POST 2 98 #define REQTYPE_PUT 4 99 char *request; 100 char *baseurl; 101 char *user; 102 CGIVAR *cgivar; 103 } WEBBLK; 104 105 106 typedef void (*zz_cgibin) (WEBBLK *webblk); 107 108 109 typedef struct _CGITAB { 110 char *path; 111 zz_cgibin cgibin; 112 } CGITAB; 113 114 115 HTTP_DLL_IMPORT void html_header (WEBBLK *webblk); 116 HTTP_DLL_IMPORT void html_footer (WEBBLK *webblk); 117 HTTP_DLL_IMPORT int html_include (WEBBLK *webblk, char *filename); 118 HTTP_DLL_IMPORT char *http_variable (WEBBLK *webblk, char *name, int type); 119 120 void *http_server (void *arg); 121 122 #endif /* _HTTPMISC_H */ 123