Changeset 156 in Main for trunk/Server/config.c
- Timestamp:
- Sep 25, 2024, 9:28:10 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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")) {
Note:
See TracChangeset
for help on using the changeset viewer.