Changeset 215 in Main for trunk/Server/server.c
- Timestamp:
- Oct 3, 2024, 4:24:43 AM (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r214 r215 16 16 #include "tw_version.h" 17 17 18 #if ndef _MSC_VER18 #if !defined(_MSC_VER) && !defined(__BORLANDC__) 19 19 #include <unistd.h> 20 20 #endif … … 33 33 #include <cm_dir.h> 34 34 35 #if defined(__MINGW32__) || defined(_MSC_VER) 35 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 36 36 #ifndef NO_GETADDRINFO 37 37 #include <ws2tcpip.h> … … 84 84 int sockets[MAX_PORTS]; 85 85 86 #if defined(__MINGW32__) || defined(_MSC_VER) 86 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 87 87 const char* reserved_names[] = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}; 88 88 #endif … … 111 111 112 112 void close_socket(int sock) { 113 #if defined(__MINGW32__) || defined(_MSC_VER) 113 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 114 114 closesocket(sock); 115 115 #else … … 120 120 int tw_server_init(void) { 121 121 int i; 122 #if defined(__MINGW32__) || defined(_MSC_VER) 122 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 123 123 WSADATA wsa; 124 124 WSAStartup(MAKEWORD(2, 0), &wsa); … … 135 135 int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); 136 136 #endif 137 #if defined(__MINGW32__) || defined(_MSC_VER) 137 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 138 138 if(sock == INVALID_SOCKET) 139 139 #else … … 238 238 doc = NULL; 239 239 } 240 #if def _MSC_VER240 #if defined(_MSC_VER) || defined(__BORLANDC__) 241 241 sprintf(construct, "%lu", (unsigned long)size); 242 242 #else … … 451 451 #if defined(__MINGW32__) || defined(_MSC_VER) 452 452 unsigned int WINAPI tw_server_pass(void* ptr) { 453 #elif defined(__BORLANDC__) 454 void tw_server_pass(void* ptr) { 453 455 #elif defined(__HAIKU__) 454 456 int32_t tw_server_pass(void* ptr) { … … 456 458 int tw_server_pass(void* ptr) { 457 459 #endif 458 #if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) 460 #if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) 459 461 #define FREE_PTR 460 462 int sock = ((struct pass_entry*)ptr)->sock; … … 549 551 struct tm* btm; 550 552 strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm); 551 #if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) 553 #if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) 552 554 t = 0; 553 555 btm = localtime(&t); … … 612 614 char* rpath; 613 615 struct stat st; 616 char* slash; 614 617 cm_log("Server", "Document root is %s", vhost_entry->root == NULL ? "not set" : vhost_entry->root); 615 618 path = cm_strcat(vhost_entry->root == NULL ? "" : vhost_entry->root, req.path); 616 619 cm_log("Server", "Filesystem path is %s", path); 617 #if defined(__MINGW32__) || defined(_MSC_VER) 620 #if defined(_MSC_VER) || defined(__BORLANDC__) 621 for(i = strlen(path) - 1; i >= 0; i--){ 622 if(path[i] == '/'){ 623 path[i] = 0; 624 }else{ 625 break; 626 } 627 } 628 #endif 629 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 618 630 rpath = cm_strdup(path); 619 631 for(i = strlen(rpath) - 1; i >= 0; i--) { … … 647 659 } else if(S_ISDIR(st.st_mode)) { 648 660 if(req.path[strlen(req.path) - 1] != '/') { 649 char* headers[3] = {"Location", cm_strcat(req.path, "/"), NULL}; 661 char* headers[3] = {"Location", NULL, NULL}; 662 headers[1] = cm_strcat(req.path, "/"); 650 663 cm_log("Server", "Accessing directory without the slash at the end"); 651 664 _tw_process_page(s, sock, tw_http_status(301), NULL, NULL, NULL, 0, headers, 0, 0); … … 885 898 #endif 886 899 close_socket(sock); 887 #if defined(__MINGW32__) || defined(_MSC_VER) 888 _endthread(0); 900 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 901 _endthread( 902 #ifndef __BORLANDC__ 903 0 904 #endif 905 ); 889 906 #elif defined(__HAIKU__) 890 907 exit_thread(0); 891 908 #endif 909 #ifndef __BORLANDC__ 892 910 return 0; 911 #endif 893 912 } 894 913 … … 898 917 #endif 899 918 900 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) 919 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) 901 920 struct thread_entry { 902 921 #ifdef __HAIKU__ … … 917 936 struct timeval tv; 918 937 #endif 919 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) 938 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) 920 939 struct thread_entry threads[2048]; 921 940 for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) { … … 948 967 #endif 949 968 if(ret == -1) { 950 #if !defined(__MINGW32__) && !defined(_MSC_VER) 969 #if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) 951 970 cm_log("Server", "Select failure: %s", strerror(errno)); 952 971 #endif … … 972 991 socklen_t clen = sizeof(claddr); 973 992 int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); 974 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) 993 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) 975 994 int j; 976 995 struct pass_entry* e = malloc(sizeof(*e)); 977 996 cm_log("Server", "New connection accepted"); 978 997 e->sock = sock; 979 #if def _MSC_VER998 #if defined(_MSC_VER) || defined(__BORLANDC__) 980 999 e->ssl = config.ports[i] & (1UL << 31); 981 1000 #else … … 985 1004 e->addr = claddr; 986 1005 #endif 987 #if defined(__MINGW32__) || defined(_MSC_VER) 1006 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) 988 1007 _beginthread(tw_server_pass, 0, e); 989 1008 #elif defined(_PSP) || defined(__PPU__)
Note:
See TracChangeset
for help on using the changeset viewer.