15 |
#include "tw_module.h" |
#include "tw_module.h" |
16 |
#include "tw_version.h" |
#include "tw_version.h" |
17 |
|
|
18 |
|
#ifdef __amiga__ |
19 |
|
#include <pthread.h> |
20 |
|
#endif |
21 |
|
|
22 |
#if !defined(_MSC_VER) && !defined(__BORLANDC__) |
#if !defined(_MSC_VER) && !defined(__BORLANDC__) |
23 |
#include <unistd.h> |
#include <unistd.h> |
24 |
#endif |
#endif |
111 |
#endif |
#endif |
112 |
#endif |
#endif |
113 |
|
|
114 |
#if defined(_PSP) || defined(__ps2sdk__) || defined(__bsdi__) |
#if defined(_PSP) || defined(__ps2sdk__) || defined(__bsdi__) || defined(__amiga__) |
115 |
#include "strptime.h" |
#include "strptime.h" |
116 |
#endif |
#endif |
117 |
|
|
348 |
while(1) { |
while(1) { |
349 |
if(f != NULL) { |
if(f != NULL) { |
350 |
char buffer[512]; |
char buffer[512]; |
351 |
|
int st; |
352 |
fread(buffer, size < 512 ? size : 512, 1, f); |
fread(buffer, size < 512 ? size : 512, 1, f); |
353 |
tw_write(ssl, sock, buffer, size < 512 ? size : 512); |
if((st = tw_write(ssl, sock, buffer, size < 512 ? size : 512)) <= 0) break; |
354 |
} else { |
} else { |
355 |
tw_write(ssl, sock, (unsigned char*)doc + incr, size < 512 ? size : 512); |
if(tw_write(ssl, sock, (unsigned char*)doc + incr, size < 512 ? size : 512) <= 0) break; |
356 |
} |
} |
357 |
incr += 512; |
incr += 512; |
358 |
if(size <= 512) break; |
if(size <= 512) break; |
519 |
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) |
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) |
520 |
#define NO_RETURN_THREAD |
#define NO_RETURN_THREAD |
521 |
void tw_server_pass(void* ptr) { |
void tw_server_pass(void* ptr) { |
522 |
|
#elif defined(__amiga__) |
523 |
|
void* tw_server_pass(void* ptr) { |
524 |
#elif defined(__HAIKU__) |
#elif defined(__HAIKU__) |
525 |
int32_t tw_server_pass(void* ptr) { |
int32_t tw_server_pass(void* ptr) { |
526 |
#elif defined(_PSP) || defined(__PPU__) |
#elif defined(_PSP) || defined(__PPU__) |
527 |
int tw_server_pass(void* ptr) { |
int tw_server_pass(void* ptr) { |
528 |
#endif |
#endif |
529 |
#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) |
#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__amiga__) |
530 |
#define FREE_PTR |
#define FREE_PTR |
531 |
int sock = ((struct pass_entry*)ptr)->sock; |
int sock = ((struct pass_entry*)ptr)->sock; |
532 |
bool ssl = ((struct pass_entry*)ptr)->ssl; |
bool ssl = ((struct pass_entry*)ptr)->ssl; |
627 |
time_t t; |
time_t t; |
628 |
struct tm* btm; |
struct tm* btm; |
629 |
strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm); |
strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm); |
630 |
#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__USLC__) || defined(__NeXT__) || defined(__bsdi__) |
#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__USLC__) || defined(__NeXT__) || defined(__bsdi__) || defined(__amiga__) |
631 |
t = 0; |
t = 0; |
632 |
btm = localtime(&t); |
btm = localtime(&t); |
633 |
cmtime = mktime(&tm); |
cmtime = mktime(&tm); |
1029 |
struct timeval tv; |
struct timeval tv; |
1030 |
#endif |
#endif |
1031 |
#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__NETWARE__) && !defined(__DOS__)) |
#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__NETWARE__) && !defined(__DOS__)) |
1032 |
struct thread_entry threads[2048]; |
struct thread_entry threads[128]; |
1033 |
for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) { |
for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) { |
1034 |
threads[i].used = false; |
threads[i].used = false; |
1035 |
} |
} |
1061 |
if(ret == -1) { |
if(ret == -1) { |
1062 |
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) |
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) |
1063 |
if(errno == EINTR) continue; |
if(errno == EINTR) continue; |
1064 |
cm_log("Server", "Select failure: %s", strerror(errno)); |
cm_log("Server", "Select/poll failure: %s", strerror(errno)); |
1065 |
#endif |
#endif |
1066 |
break; |
break; |
1067 |
} else if(ret == 0) { |
} else if(ret == 0) { |
1084 |
SOCKADDR claddr; |
SOCKADDR claddr; |
1085 |
socklen_t clen = sizeof(claddr); |
socklen_t clen = sizeof(claddr); |
1086 |
int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); |
int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); |
1087 |
#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) |
#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__amiga__) |
1088 |
|
#ifdef __amiga__ |
1089 |
|
pthread_t thrt; |
1090 |
|
#endif |
1091 |
int j; |
int j; |
1092 |
struct pass_entry* e = malloc(sizeof(*e)); |
struct pass_entry* e = malloc(sizeof(*e)); |
1093 |
cm_log("Server", "New connection accepted"); |
cm_log("Server", "New connection accepted"); |
1112 |
#endif |
#endif |
1113 |
#elif defined(_PSP) || defined(__PPU__) |
#elif defined(_PSP) || defined(__PPU__) |
1114 |
tw_server_pass(e); |
tw_server_pass(e); |
1115 |
|
#elif defined(__amiga__) |
1116 |
|
pthread_create(&thrt, NULL, tw_server_pass, e); |
1117 |
#elif defined(__HAIKU__) |
#elif defined(__HAIKU__) |
1118 |
for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { |
for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { |
1119 |
if(threads[j].used) { |
if(threads[j].used) { |