Changeset 33 in Main for trunk/Server/server.c
- Timestamp:
- Sep 16, 2024, 9:52:47 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r32 r33 513 513 addstring(&str, " <th>Size</th>\n"); 514 514 addstring(&str, " </tr>\n"); 515 int readme = -1; 516 char** readmes = vhost_entry->readme_count == 0 ? config.root.readmes : vhost_entry->readmes; 517 int readme_count = vhost_entry->readme_count == 0 ? config.root.readme_count : vhost_entry->readme_count; 515 518 if(items != NULL) { 516 519 int phase = 0; 517 520 doit: 518 521 for(i = 0; items[i] != NULL; i++) { 522 int j; 519 523 char* fpth = cm_strcat3(path, "/", items[i]); 520 524 struct stat s; … … 529 533 continue; 530 534 } 535 if(readme == -1) { 536 for(j = 0; j < readme_count; j++) { 537 if(strcmp(items[i], readmes[j]) == 0) { 538 readme = j; 539 break; 540 } 541 } 542 if(readme != -1) { 543 free(fpth); 544 continue; 545 } 546 } 531 547 if(s.st_size < 1024ULL) { 532 548 sprintf(size, "%d", (int)s.st_size); … … 544 560 545 561 char* ext = NULL; 546 int j;547 562 for(j = strlen(items[i]) - 1; j >= 0; j--) { 548 563 if(items[i][j] == '.') { … … 595 610 } 596 611 addstring(&str, " </table>\n"); 612 if(readme != -1) { 613 addstring(&str, "<hr>\n"); 614 char* fpth = cm_strcat3(path, "/", readmes[readme]); 615 struct stat s; 616 stat(fpth, &s); 617 FILE* fr = fopen(fpth, "r"); 618 if(fr != NULL) { 619 char* rmbuf = malloc(s.st_size + 1); 620 rmbuf[s.st_size] = 0; 621 fread(rmbuf, s.st_size, 1, fr); 622 addstring(&str, "<pre><code>%h</code></pre>\n", rmbuf); 623 fclose(fr); 624 } 625 } 597 626 addstring(&str, " <hr>\n"); 598 627 addstring(&str, " <address>%s Server at %s Port %d</address>\n", tw_server, name, port);
Note:
See TracChangeset
for help on using the changeset viewer.