Changeset 257 in Main for trunk/Server/config.c
- Timestamp:
- Oct 4, 2024, 2:34:27 PM (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/config.c
r255 r257 10 10 #include <stdlib.h> 11 11 #include <string.h> 12 #include <sys/stat.h> 12 13 13 14 #if !defined(_MSC_VER) && !defined(__BORLANDC__) … … 405 406 e->mime = cm_strdup(r[2]); 406 407 } 408 } else if(cm_strcaseequ(r[0], "MIMEFile")) { 409 if(r[1] == NULL) { 410 cm_log("Config", "Missing path at line %d", ln); 411 stop = 1; 412 } else { 413 FILE* mimefile = fopen(r[1], "r"); 414 if(mimefile == NULL) { 415 cm_log("Config", "Could not load the file at line %d", ln); 416 stop = 1; 417 } else { 418 char* line = malloc(1); 419 int i; 420 struct stat st; 421 char* buf; 422 int incr = 0; 423 stat(r[1], &st); 424 425 buf = malloc(st.st_size + 1); 426 fread(buf, st.st_size, 1, mimefile); 427 428 for(i = 0;; i++) { 429 if(buf[i] == '\n' || buf[i] == 0) { 430 char oldc = buf[i]; 431 char* line; 432 buf[i] = 0; 433 434 line = buf + incr; 435 436 if(strlen(line) > 0 && line[0] != '#') { 437 int j; 438 for(j = 0; line[j] != 0; j++) { 439 if(line[j] == ' ' || line[j] == '\t') { 440 line[j] = 0; 441 j++; 442 for(; line[j] != 0; j++) { 443 if(line[j] != ' ' && line[j] != '\t') { 444 char* name = line; 445 char* mimes = line + j; 446 int k = 0; 447 int incr2 = 0; 448 for(k = 0;; k++) { 449 if(mimes[k] == ' ' || mimes[k] == 0) { 450 char oldc2 = mimes[k]; 451 struct tw_mime_entry* e; 452 mimes[k] = 0; 453 454 e = ¤t->mimes[current->mime_count++]; 455 e->ext = cm_strcat(".", mimes + incr2); 456 e->mime = cm_strdup(name); 457 if(current->mime_count == MAX_MIME) { 458 cm_log("Config", "Too many MIME types, cannot handle"); 459 stop = 1; 460 break; 461 } 462 463 incr2 = k + 1; 464 if(oldc2 == 0) break; 465 } 466 } 467 break; 468 } 469 } 470 break; 471 } 472 if(stop) break; 473 } 474 } 475 476 incr = i + 1; 477 if(oldc == 0) break; 478 } 479 } 480 481 free(buf); 482 483 fclose(mimefile); 484 } 485 } 407 486 } else if(cm_strcaseequ(r[0], "Icon")) { 408 487 if(r[1] == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.