Changeset 33 in Main for trunk/Server
- Timestamp:
- Sep 16, 2024, 9:52:47 PM (2 months ago)
- Location:
- trunk/Server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/config.c
r24 r33 84 84 config.root.icon_count = 0; 85 85 config.root.index_count = 0; 86 config.root.readme_count = 0; 86 87 config.vhost_count = 0; 87 88 config.module_count = 0; … … 184 185 current->icon_count = 0; 185 186 current->index_count = 0; 187 current->readme_count = 0; 186 188 int i; 187 189 current->name = cm_strdup(vhost); … … 288 290 for(i = 1; r[i] != NULL; i++) { 289 291 current->indexes[current->index_count++] = cm_strdup(r[i]); 292 } 293 } else if(cm_strcaseequ(r[0], "Readme")) { 294 for(i = 1; r[i] != NULL; i++) { 295 current->readmes[current->readme_count++] = cm_strdup(r[i]); 290 296 } 291 297 } else { -
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); -
trunk/Server/tw_config.h
r24 r33 29 29 #define MAX_ICON 1024 30 30 #define MAX_INDEX 1024 31 #define MAX_README 8 31 32 32 33 enum TW_DIR_TYPE { … … 65 66 char* indexes[MAX_INDEX]; 66 67 int index_count; 68 char* readmes[MAX_README]; 69 int readme_count; 67 70 }; 68 71 -
trunk/Server/version.c
r27 r33 5 5 #include "tw_version.h" 6 6 7 const char* tw_version = " 0.00";7 const char* tw_version = "1.00"; 8 8 9 9 const char* tw_platform =
Note:
See TracChangeset
for help on using the changeset viewer.