From: Nishi Date: Sun, 13 Oct 2024 18:17:37 +0000 (+0000) Subject: works on os2 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=7e03e2932a29382efa359ac86ee7f1c197d164b8;p=tewi.git works on os2 git-svn-id: file:///raid/svn-personal/tewi/trunk@312 8739d7e6-ffea-ec47-b151-bdff447c6205 --- diff --git a/Makefile b/Makefile index e097270..f86e025 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,9 @@ install: all ./Tool/genconf ./Tool/itworks if [ ! -e $(DESTDIR)$(PREFIX)/www/index.html ]; then ( ./Tool/itworks > $(DESTDIR)$(PREFIX)/www/index.html || ( rm $(DESTDIR)$(PREFIX)/www/index.html ; exit 1 ) ) ; fi if [ ! -e $(DESTDIR)$(PREFIX)/www/pbtewi.gif ]; then ( cp Binary/pbtewi.gif $(DESTDIR)$(PREFIX)/www/ || ( rm $(DESTDIR)$(PREFIX)/www/pbtewi.gif ; exit 1 ) ) ; fi -cp ./Server/tewi $(DESTDIR)$(PREFIX)/bin/ + -cp ./Server/tewi.exe $(DESTDIR)$(PREFIX)/bin/ -cp ./Module/*.so $(DESTDIR)$(PREFIX)/lib/tewi/ + -cp ./Module/*.dll $(DESTDIR)$(PREFIX)/lib/tewi/ format: clang-format --verbose -i `find ./Server ./Common ./Module ./Tool "(" -name "*.c" -or -name "*.h" ")" -and -not -name "strptime.*"` config.h diff --git a/Platform/os2.mk b/Platform/os2.mk index e4292f6..64971c8 100644 --- a/Platform/os2.mk +++ b/Platform/os2.mk @@ -6,12 +6,10 @@ PLATFORM_IDENT = OS2_WATCOM CC = owcc AR = wlib AR_FLAGS = -q -b -n -fo -CFLAGS = -b os2v2$(END) -I $(WATCOM)/h/os2 -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC +CFLAGS = -b os2v2$(END) -I $(WATCOM)/h/os2 -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC -D__WATCOM_LFN__ LDFLAGS = -b os2v2$(END) LIBS = EXEC = .exe STATIC = lib LIBSUF = .dll OBJ = obj -REQOBJS = concat.rc -SERVADD = wrc -bt=nt -i=$(WATCOM)/h/nt concat.rc tewi.exe diff --git a/Server/config.c b/Server/config.c index a998d67..fdcbc06 100644 --- a/Server/config.c +++ b/Server/config.c @@ -2,8 +2,7 @@ #define SOURCE -#include "tw_config.h" -#include "tw_module.h" +#include "../config.h" #include #include @@ -15,7 +14,7 @@ #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__WATCOMC__)) #ifdef USE_WINSOCK1 #include #else @@ -26,6 +25,15 @@ #include #include +#ifdef __OS2__ +#include +#include +#include +#endif + +#include "tw_config.h" +#include "tw_module.h" + struct tw_config config; struct tw_config_entry* tw_vhost_match(const char* name, int port) { diff --git a/Server/http.c b/Server/http.c index 22aae28..b875c18 100644 --- a/Server/http.c +++ b/Server/http.c @@ -15,7 +15,13 @@ #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ +#include +#include +#include +#endif + +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) #ifdef USE_WINSOCK1 #include #else diff --git a/Server/main.c b/Server/main.c index 6eb6136..7b8abe2 100644 --- a/Server/main.c +++ b/Server/main.c @@ -23,6 +23,10 @@ #include #endif +#ifdef __OS2__ +#include +#endif + #include #include @@ -801,7 +805,7 @@ int startup(int argc, char** argv) { #if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); -#elif !defined(BUILD_GUI) +#elif !defined(BUILD_GUI) && !defined(__OS2__) SetConsoleTitle(tw_server); #endif return -1; diff --git a/Server/module.c b/Server/module.c index 02eb5c6..d763900 100644 --- a/Server/module.c +++ b/Server/module.c @@ -27,8 +27,13 @@ int tw_module_init(void* mod) { return 1; } #else #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ +#define INCL_DOSMODULEMGR +#include +#else #include #include +#endif #else #include #endif @@ -36,9 +41,17 @@ int tw_module_init(void* mod) { return 1; } void* tw_module_load(const char* path) { char* p = getcwd(NULL, 0); void* lib; + char tmp[512]; + unsigned long l; chdir(config.server_root); #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ + lib = NULL; + l = (unsigned long)lib; + DosLoadModule(tmp, 512, path, &l); +#else lib = LoadLibraryA(path); +#endif #else lib = dlopen(path, RTLD_LAZY); #endif @@ -52,7 +65,13 @@ void* tw_module_load(const char* path) { void* tw_module_symbol(void* mod, const char* sym) { #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ + void* ret; + DosQueryProcAddr((unsigned long)mod, 0, sym, (PFN*)&ret); + return ret; +#else return GetProcAddress(mod, sym); +#endif #else return dlsym(mod, sym); #endif diff --git a/Server/server.c b/Server/server.c index 2069b6a..2e33661 100644 --- a/Server/server.c +++ b/Server/server.c @@ -18,6 +18,7 @@ #if !defined(_MSC_VER) && !defined(__BORLANDC__) #include #endif +#include #include #include #include @@ -32,6 +33,20 @@ #include #include +#ifdef __OS2__ +#include +#include +#define INCL_DOSPROCESS +#include +#include +#define HANDLE void* + +#include "strptime.h" +typedef int socklen_t; + +#include +#endif + #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) #ifndef NO_GETNAMEINFO #include @@ -108,7 +123,7 @@ int tw_wildcard_match(const char* wildcard, const char* target) { return 0; } else if(*pw == '*') { return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt); - } else if(*pw == '?' || (*pw == *pt)) { + } else if(*pw == '?' || (tolower(*pw) == tolower(*pt))) { pw++; pt++; continue; @@ -119,7 +134,9 @@ int tw_wildcard_match(const char* wildcard, const char* target) { } void close_socket(int sock) { -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ + soclose(sock); +#elif defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) closesocket(sock); #else close(sock); @@ -128,13 +145,16 @@ void close_socket(int sock) { int tw_server_init(void) { int i; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) WSADATA wsa; #ifdef USE_WINSOCK1 WSAStartup(MAKEWORD(1, 1), &wsa); #else WSAStartup(MAKEWORD(2, 0), &wsa); #endif +#endif +#ifdef __OS2__ + sock_init(); #endif for(i = 0; config.ports[i] != -1; i++) ; @@ -1019,7 +1039,11 @@ void tw_server_loop(void) { e->addr = claddr; #endif #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __OS2__ + _beginthread(tw_server_pass, 0, 0, e); +#else _beginthread(tw_server_pass, 0, e); +#endif #elif defined(_PSP) || defined(__PPU__) tw_server_pass(e); #elif defined(__HAIKU__) diff --git a/Server/strptime.c b/Server/strptime.c index e89f5fa..02dbe55 100644 --- a/Server/strptime.c +++ b/Server/strptime.c @@ -462,7 +462,7 @@ recurse: bp = NULL; continue; } -#ifdef _WIN32 +#if defined(_WIN32) || defined(__OS2__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) if (1) #else diff --git a/Server/strptime.h b/Server/strptime.h index e792cf1..da44d6a 100644 --- a/Server/strptime.h +++ b/Server/strptime.h @@ -7,7 +7,7 @@ extern "C" { #include -#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) +#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) char* strptime(const char *buf, const char *fmt, struct tm *tm); #endif diff --git a/Server/tw_config.h b/Server/tw_config.h index 7d25563..93cefb9 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -25,13 +25,15 @@ extern "C" { #ifdef __PPU__ #include #endif +#if !defined(__OS2__) #include +#endif #ifdef __HAIKU__ #define NO_IPV6 #endif #endif -#ifdef NO_IPV6 +#if defined(NO_IPV6) #define SOCKADDR struct sockaddr_in #else #define SOCKADDR struct sockaddr_in6 diff --git a/Server/version.c b/Server/version.c index 2c3112a..455d4ec 100644 --- a/Server/version.c +++ b/Server/version.c @@ -15,6 +15,8 @@ const char* tw_platform = "OpenBSD" #elif defined(__linux__) "Linux" +#elif defined(__OS2__) + "OS/2" #elif defined(__MINGW32__) "Windows-MinGW32" #elif defined(_MSC_VER) diff --git a/config.h.tmpl b/config.h.tmpl index 5025b2f..5323cf4 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -68,6 +68,10 @@ /* Minix does not have IPv6 */ #endif +#if defined(__WATCOMC__) && defined(__OS2__) && !defined(NO_IPV6) +#define NO_IPV6 +#endif + #endif /*