- Timestamp:
- Sep 25, 2024, 9:28:10 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r152 r156 9 9 FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX) 10 10 11 .PHONY: all format clean ./Server ./Common ./Module ./Manpageget-version11 .PHONY: all format clean ./Server ./Common ./Module get-version 12 12 13 13 all: ./Server ./Module ./Manpage ./Tool/genconf ./Tool/itworks … … 31 31 $(MAKE) -C $@ $(FLAGS) 32 32 33 ./Manpage:: 34 $(MAKE) -C $@ $(FLAGS) 35 36 ./README: ./README.tmpl 33 ./README: ./README.tmpl ./Server/tw_version.h 37 34 sed "s/@VERSION@/`grep "define TW_VERSION" Server/tw_version.h | grep -Eo '"[^\]+' | sed -E 's/^"//g'`/g" ./README.tmpl > $@ 38 35 … … 44 41 cp ./Server/tewi $(PREFIX)/bin/ 45 42 cp ./Module/*.so $(PREFIX)/lib/tewi/ 46 cp ./Manpage/tewi.8 $(PREFIX)/share/man/man8/47 43 48 44 format: … … 56 52 $(MAKE) -C ./Module $(FLAGS) clean 57 53 $(MAKE) -C ./Common $(FLAGS) clean 58 $(MAKE) -C ./Manpage $(FLAGS) clean59 54 rm -f ./Tool/option ./Tool/genconf -
trunk/README
r155 r156 1 1 2 Tewi HTTPd version 1.0 6C2 Tewi HTTPd version 1.07 3 3 4 4 Original by Nishi <nishi@nishi.boats> -
trunk/Server/config.c
r138 r156 73 73 } 74 74 for(i = 0; i < MAX_VHOSTS; i++) { 75 #ifndef NO_SSL 75 76 config.vhosts[i].sslkey = NULL; 76 77 config.vhosts[i].sslcert = NULL; 78 #endif 77 79 config.vhosts[i].root = NULL; 78 } 80 #ifdef HAS_CHROOT 81 config.vhosts[i].chroot_path = NULL; 82 #endif 83 } 84 #ifndef NO_SSL 79 85 config.root.sslkey = NULL; 80 86 config.root.sslcert = NULL; 87 #endif 81 88 config.root.root = NULL; 82 89 config.root.mime_count = 0; … … 86 93 config.root.readme_count = 0; 87 94 config.root.hideport = 0; 95 #ifdef HAS_CHROOT 96 config.root.chroot_path = NULL; 97 #endif 88 98 config.vhost_count = 0; 89 99 config.module_count = 0; … … 91 101 config.server_root = cm_strdup(PREFIX); 92 102 config.server_admin = cm_strdup(SERVER_ADMIN); 103 config.defined[0] = NULL; 93 104 gethostname(config.hostname, 1024); 94 105 } … … 99 110 cbuf[1] = 0; 100 111 int ln = 0; 112 int ifbr = 0; 113 int ignore = -1; 101 114 FILE* f = fopen(path, "r"); 102 115 if(f != NULL) { … … 115 128 char** r = cm_split(l, " \t"); 116 129 int i; 117 if(cm_strcaseequ(r[0], "Include") || cm_strcaseequ(r[0], "IncludeOptional")) { 130 if(ignore != -1 && ifbr >= ignore) { 131 if(cm_strcaseequ(r[0], "EndIf")) ifbr--; 132 if(ifbr == 0) { 133 ignore = -1; 134 } 135 } else if(cm_strcaseequ(r[0], "Include") || cm_strcaseequ(r[0], "IncludeOptional")) { 118 136 for(i = 1; r[i] != NULL; i++) { 119 137 if(tw_config_read(r[i]) != 0 && cm_strcaseequ(r[0], "Include")) { … … 121 139 break; 122 140 } 141 } 142 } else if(cm_strcaseequ(r[0], "Define")) { 143 if(r[1] == NULL) { 144 cm_log("Config", "Missing name at line %d", ln); 145 stop = 1; 146 } else { 147 tw_add_define(r[1]); 148 } 149 } else if(cm_strcaseequ(r[0], "Undefine")) { 150 if(r[1] == NULL) { 151 cm_log("Config", "Missing name at line %d", ln); 152 stop = 1; 153 } else { 154 tw_delete_define(r[1]); 123 155 } 124 156 } else if(cm_strcaseequ(r[0], "BeginDirectory")) { … … 224 256 } else if(cm_strcaseequ(r[0], "ShowPort")) { 225 257 current->hideport = 0; 258 #ifndef NO_SSL 226 259 } else if(cm_strcaseequ(r[0], "SSLKey")) { 227 260 if(r[1] == NULL) { … … 239 272 if(current->sslcert != NULL) free(current->sslcert); 240 273 current->sslcert = cm_strdup(r[1]); 274 } 275 #endif 276 } else if(cm_strcaseequ(r[0], "ForceLog")) { 277 if(r[1] == NULL) { 278 cm_log("Config", "Missing log at line %d", ln); 279 stop = 1; 280 } else { 281 cm_force_log(r[1]); 282 } 283 } else if(cm_strcaseequ(r[0], "EndIf")) { 284 if(ifbr == 0) { 285 cm_log("Config", "Missing BeginIf at line %d", ln); 286 stop = 1; 287 } 288 ifbr--; 289 } else if(cm_strcaseequ(r[0], "BeginIf") || cm_strcaseequ(r[0], "BeginIfNot")) { 290 if(r[1] == NULL) { 291 cm_log("Config", "Missing condition type at line %d", ln); 292 } else { 293 ifbr++; 294 bool ign = false; 295 if(cm_strcaseequ(r[1], "False")) { 296 ign = true; 297 } else if(cm_strcaseequ(r[1], "True")) { 298 } else if(cm_strcaseequ(r[1], "Defined")) { 299 if(r[2] == NULL) { 300 cm_log("Config", "Missing name at line %d", ln); 301 stop = 1; 302 } else { 303 int i; 304 bool fndit = false; 305 for(i = 0; config.defined[i] != NULL; i++) { 306 if(strcmp(config.defined[i], r[2]) == 0) { 307 fndit = true; 308 break; 309 } 310 } 311 if(!fndit) { 312 ign = true; 313 } 314 } 315 } else { 316 cm_log("Config", "Unknown condition type at line %d", ln); 317 stop = 1; 318 } 319 if(cm_strcaseequ(r[0], "BeginIfNot")) ign = !ign; 320 if(ign) { 321 ignore = ifbr - 1; 322 } 241 323 } 242 324 } else if(cm_strcaseequ(r[0], "ServerRoot")) { -
trunk/Server/module.c
r25 r156 10 10 #include <cm_log.h> 11 11 12 #include <string.h> 12 13 #include <unistd.h> 13 14 #include <stdlib.h> … … 56 57 } 57 58 59 void tw_add_define(const char* string) { 60 int i; 61 for(i = 0; config.defined[i] != NULL; i++) 62 ; 63 config.defined[i] = cm_strdup(string); 64 config.defined[i + 1] = NULL; 65 } 66 67 void tw_delete_define(const char* string) { 68 int i; 69 for(i = 0; config.defined[i] != NULL; i++) { 70 if(strcmp(config.defined[i], string) == 0) { 71 free(config.defined[i]); 72 for(; config.defined[i] != NULL; i++) { 73 config.defined[i] = config.defined[i + 1]; 74 } 75 } 76 } 77 } 78 58 79 void tw_init_tools(struct tw_tool* tools) { 59 80 tools->log = cm_log; 60 81 tools->add_version = tw_add_version; 82 tools->add_define = tw_add_define; 61 83 } 62 84 -
trunk/Server/tw_config.h
r140 r156 7 7 extern "C" { 8 8 #endif 9 10 #include "../config.h" 9 11 10 12 #include "tw_http.h" … … 62 64 char* name; 63 65 int port; 66 #ifndef NO_SSL 64 67 char* sslkey; 65 68 char* sslcert; 69 #endif 66 70 char* root; 67 71 int hideport; … … 76 80 char* readmes[MAX_README]; 77 81 int readme_count; 82 #ifdef HAS_CHROOT 83 char* chroot_path; 84 #endif 78 85 }; 79 86 … … 81 88 uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */ 82 89 char hostname[1025]; 90 char* defined[1025]; 83 91 struct tw_config_entry root; 84 92 struct tw_config_entry vhosts[MAX_VHOSTS]; -
trunk/Server/tw_module.h
r141 r156 14 14 void (*log)(const char* name, const char* log, ...); 15 15 void (*add_version)(const char* string); 16 void (*add_define)(const char* string); 17 void (*delete_define)(const char* string); 16 18 }; 17 19 … … 45 47 void tw_init_tools(struct tw_tool* tools); 46 48 int tw_module_init(void* mod); 49 50 void tw_add_version(const char* string); 51 void tw_add_define(const char* string); 52 void tw_delete_define(const char* string); 47 53 #endif 48 54 -
trunk/Server/tw_version.h
r151 r156 8 8 #endif 9 9 10 #define TW_VERSION "1.0 6C\0"10 #define TW_VERSION "1.07\0" 11 11 12 12 const char* tw_get_version(void); -
trunk/config.h.tmpl
r128 r156 8 8 #undef NO_SSL 9 9 #define USE_POLL 10 #define HAS_CHROOT 10 11 11 12 /* DO NOT EDIT BELOW THIS LINE */ … … 20 21 #endif 21 22 23 #if defined(__MINGW32__) && defined(HAS_CHROOT) 24 #undef HAS_CHROOT 25 /* Windows should not have chroot */ 26 #endif 27 22 28 #endif 23 29 -
trunk/example.conf
r150 r156 5 5 6 6 #LoadModule Module/mod_cgi.so 7 LoadModule Module/mod_proxy.so7 #LoadModule Module/mod_proxy.so 8 8 9 9 Listen 80 … … 30 30 DocumentRoot /var/www 31 31 32 #ProxyPass 32 Define test 33 Undefine test 34 35 BeginIf Defined test 36 ForceLog "defined" 37 EndIf 38 BeginIfNot Defined test 39 ForceLog "not defined" 40 EndIf
Note:
See TracChangeset
for help on using the changeset viewer.