From c41a0c1e927cbbed2fbf166bdd05ce8c4d394228 Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 2 Oct 2024 20:40:37 +0000 Subject: [PATCH] add watcom git-svn-id: file:///raid/svn-personal/tewi/trunk@219 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Common/dir.c | 4 +++- Module/Makefile | 1 + Platform/watcom.mk | 14 ++++++++++++++ Server/http.c | 2 +- Server/main.c | 2 +- Server/module.c | 6 +++--- Server/server.c | 30 +++++++++++++++--------------- Server/strptime.c | 2 +- Server/tw_config.h | 2 +- Server/version.c | 6 ++++-- config.h.tmpl | 6 +++--- 11 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 Platform/watcom.mk diff --git a/Common/dir.c b/Common/dir.c index eae03e4..8ba4772 100644 --- a/Common/dir.c +++ b/Common/dir.c @@ -5,8 +5,10 @@ #include "cm_string.h" #include -#ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(__WATCOMC__) #include +#elif defined(__WATCOMC__) +#include #endif #include #include diff --git a/Module/Makefile b/Module/Makefile index 00cea8c..3f8cde7 100644 --- a/Module/Makefile +++ b/Module/Makefile @@ -2,6 +2,7 @@ OBJ=o STATIC=a +END=_dll include $(PWD)/Platform/$(PLATFORM).mk .PHONY: all clean diff --git a/Platform/watcom.mk b/Platform/watcom.mk new file mode 100644 index 0000000..607fe22 --- /dev/null +++ b/Platform/watcom.mk @@ -0,0 +1,14 @@ +# $Id$ + +PREFIX = C:/Tewi + +CC = owcc +AR = wlib +AR_FLAGS = -q -b -n -fo +CFLAGS = -b nt$(END) -I $(WATCOM)/h/nt -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC +LDFLAGS = -b nt$(END) +LIBS = ws2_32.lib +EXEC = .exe +STATIC = lib +LIBSUF = .dll +OBJ = obj diff --git a/Server/http.c b/Server/http.c index e5fab0e..b98e0ae 100644 --- a/Server/http.c +++ b/Server/http.c @@ -15,7 +15,7 @@ #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #include #else #ifdef USE_POLL diff --git a/Server/main.c b/Server/main.c index a418157..b84a5e6 100644 --- a/Server/main.c +++ b/Server/main.c @@ -789,7 +789,7 @@ int startup(int argc, char** argv) { r = cm_strcat(tw_server, " running..."); cm_force_log(r); free(r); -#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) +#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); #else diff --git a/Server/module.c b/Server/module.c index 90fd598..02eb5c6 100644 --- a/Server/module.c +++ b/Server/module.c @@ -26,7 +26,7 @@ int tw_module_init(void* mod) { return 1; } #else -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #include #include #else @@ -37,7 +37,7 @@ void* tw_module_load(const char* path) { char* p = getcwd(NULL, 0); void* lib; chdir(config.server_root); -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) lib = LoadLibraryA(path); #else lib = dlopen(path, RTLD_LAZY); @@ -51,7 +51,7 @@ void* tw_module_load(const char* path) { } void* tw_module_symbol(void* mod, const char* sym) { -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) return GetProcAddress(mod, sym); #else return dlsym(mod, sym); diff --git a/Server/server.c b/Server/server.c index 8111304..3dc7226 100644 --- a/Server/server.c +++ b/Server/server.c @@ -32,7 +32,7 @@ #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #ifndef NO_GETADDRINFO #include #include @@ -84,7 +84,7 @@ int sockcount = 0; SOCKADDR addresses[MAX_PORTS]; int sockets[MAX_PORTS]; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) 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"}; #endif @@ -111,7 +111,7 @@ int tw_wildcard_match(const char* wildcard, const char* target) { } void close_socket(int sock) { -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) closesocket(sock); #else close(sock); @@ -120,7 +120,7 @@ void close_socket(int sock) { int tw_server_init(void) { int i; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) WSADATA wsa; WSAStartup(MAKEWORD(2, 0), &wsa); #endif @@ -449,7 +449,7 @@ struct pass_entry { SOCKADDR addr; }; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #define NO_RETURN_THREAD void tw_server_pass(void* ptr) { #elif defined(__HAIKU__) @@ -457,7 +457,7 @@ int32_t tw_server_pass(void* ptr) { #elif defined(_PSP) || defined(__PPU__) int tw_server_pass(void* ptr) { #endif -#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #define FREE_PTR int sock = ((struct pass_entry*)ptr)->sock; bool ssl = ((struct pass_entry*)ptr)->ssl; @@ -551,7 +551,7 @@ int tw_server_pass(void* ptr) { time_t t; struct tm* btm; strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm); -#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) t = 0; btm = localtime(&t); cmtime = mktime(&tm); @@ -618,7 +618,7 @@ int tw_server_pass(void* ptr) { cm_log("Server", "Document root is %s", vhost_entry->root == NULL ? "not set" : vhost_entry->root); path = cm_strcat(vhost_entry->root == NULL ? "" : vhost_entry->root, req.path); cm_log("Server", "Filesystem path is %s", path); -#if defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) for(i = strlen(path) - 1; i >= 0; i--) { if(path[i] == '/') { path[i] = 0; @@ -627,7 +627,7 @@ int tw_server_pass(void* ptr) { } } #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) rpath = cm_strdup(path); for(i = strlen(rpath) - 1; i >= 0; i--) { if(rpath[i] == '/') { @@ -898,7 +898,7 @@ cleanup: SSL_free(s); #endif close_socket(sock); -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) _endthread(); #elif defined(__HAIKU__) exit_thread(0); @@ -913,7 +913,7 @@ extern SERVICE_STATUS status; extern SERVICE_STATUS_HANDLE status_handle; #endif -#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) struct thread_entry { #ifdef __HAIKU__ thread_id thread; @@ -932,7 +932,7 @@ void tw_server_loop(void) { fd_set fdset; struct timeval tv; #endif -#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) struct thread_entry threads[2048]; for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) { threads[i].used = false; @@ -963,7 +963,7 @@ void tw_server_loop(void) { #endif #endif if(ret == -1) { -#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) +#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) cm_log("Server", "Select failure: %s", strerror(errno)); #endif break; @@ -987,7 +987,7 @@ void tw_server_loop(void) { SOCKADDR claddr; socklen_t clen = sizeof(claddr); int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); -#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) int j; struct pass_entry* e = malloc(sizeof(*e)); cm_log("Server", "New connection accepted"); @@ -1000,7 +1000,7 @@ void tw_server_loop(void) { e->port = config.ports[i]; e->addr = claddr; #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) _beginthread(tw_server_pass, 0, e); #elif defined(_PSP) || defined(__PPU__) tw_server_pass(e); diff --git a/Server/strptime.c b/Server/strptime.c index 1000af6..feea882 100644 --- a/Server/strptime.c +++ b/Server/strptime.c @@ -35,7 +35,7 @@ //#include //__RCSID("$NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $"); -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #include #include diff --git a/Server/tw_config.h b/Server/tw_config.h index d640ae1..6059e07 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -14,7 +14,7 @@ extern "C" { #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #include #define NO_IPV6 #else diff --git a/Server/version.c b/Server/version.c index a0c4cfc..25abdd1 100644 --- a/Server/version.c +++ b/Server/version.c @@ -16,9 +16,11 @@ const char* tw_platform = #elif defined(__MINGW32__) "Windows-MinGW32" #elif defined(_MSC_VER) - "Windows-MSVC" + "Windows-VisualC" #elif defined(__BORLANDC__) - "Windows-BCC" + "Windows-Borland" +#elif defined(__WATCOMC__) + "Windows-Watcom" #elif defined(__HAIKU__) "Haiku" #elif defined(__CYGWIN__) diff --git a/config.h.tmpl b/config.h.tmpl index 956ab1c..97801a2 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -17,17 +17,17 @@ #define SSL void #endif -#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)) && defined(USE_POLL) +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_POLL) #undef USE_POLL /* Force select(2) for Windows */ #endif -#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)) && defined(HAS_CHROOT) +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(HAS_CHROOT) #undef HAS_CHROOT /* Windows should not have chroot */ #endif -#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(NO_GETADDRINFO) +#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && !defined(NO_GETADDRINFO) #define NO_GETADDRINFO /* Do not use getaddrinfo */ #endif -- 2.43.0