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