From 93e408ba627c3123ca3e63b3d8565dd7132951e8 Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 16 Oct 2024 14:34:51 +0000 Subject: [PATCH] add dos supportr git-svn-id: file:///raid/svn-personal/tewi/trunk@359 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Platform/dos.mk | 16 ++++++++++++++++ README | 1 + README.tmpl | 1 + Server/config.c | 2 +- Server/http.c | 2 +- Server/main.c | 15 +++++++++++---- Server/module.c | 2 +- Server/server.c | 15 +++++++++++++-- Server/strptime.c | 2 +- Server/strptime.h | 2 +- Server/tw_config.h | 2 +- Server/version.c | 2 ++ config_platform.h | 4 ++++ 13 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 Platform/dos.mk diff --git a/Platform/dos.mk b/Platform/dos.mk new file mode 100644 index 0000000..a324eeb --- /dev/null +++ b/Platform/dos.mk @@ -0,0 +1,16 @@ +# $Id$ + +PREFIX = C:/Tewi + +PLATFORM_IDENT = DOS_WATCOM +CC = owcc +AR = wlib +AR_FLAGS = -q -b -n -fo +CFLAGS = -b dos4g$(END) -I $(WATCOM)/h -I $(PWD)/watt32/inc -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC +LDFLAGS = -b dos4g$(END) +LIBS = $(PWD)/watt32/lib/wattcpwf.lib +EXEC = .exe +STATIC = lib +LIBSUF = .dll +OBJ = obj +MODULE= diff --git a/README b/README index ec6a1b4..f2cbcc7 100644 --- a/README +++ b/README @@ -46,6 +46,7 @@ Haiku Working Minix Working UnixWare Working on 7.1.1 OS/2 Working +DOS Working, missing module support and multi-threading NeXTSTEP Working, missing module support PlayStation Portable Working, missing module support TODO: Get multi-threading working (maybe) diff --git a/README.tmpl b/README.tmpl index 300843b..0d15b56 100644 --- a/README.tmpl +++ b/README.tmpl @@ -46,6 +46,7 @@ Haiku Working Minix Working UnixWare Working on 7.1.1 OS/2 Working +DOS Working, missing module support and multi-threading NeXTSTEP Working, missing module support PlayStation Portable Working, missing module support TODO: Get multi-threading working (maybe) diff --git a/Server/config.c b/Server/config.c index 53d860e..dea4244 100644 --- a/Server/config.c +++ b/Server/config.c @@ -14,7 +14,7 @@ #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) #ifdef USE_WINSOCK1 #include #else diff --git a/Server/http.c b/Server/http.c index cf74139..8357759 100644 --- a/Server/http.c +++ b/Server/http.c @@ -21,7 +21,7 @@ #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) #ifdef USE_WINSOCK1 #include #else diff --git a/Server/main.c b/Server/main.c index 2400b33..b5c7000 100644 --- a/Server/main.c +++ b/Server/main.c @@ -27,6 +27,10 @@ #include #endif +#ifdef __DOS__ +#include +#endif + #include #include @@ -34,7 +38,7 @@ #include "tw_server.h" #include "tw_version.h" -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) #include #elif defined(__NETWARE__) #endif @@ -93,7 +97,7 @@ char tw_server[2048]; int startup(int argc, char** argv); -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) char* get_registry(const char* main, const char* sub) { DWORD bufsize = 512; HKEY handle; @@ -750,7 +754,7 @@ void thread_stuff(void* pargs) { int startup(int argc, char** argv) { int i; char* r; -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) char* confpath = cm_strdup(PREFIX "/etc/tewi.conf"); char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir"); if(regpath != NULL) { @@ -823,6 +827,9 @@ int startup(int argc, char** argv) { STDERR_LOG("Could not read the config\n"); return 1; } +#ifdef __DOS__ + sock_init(); +#endif if(tw_server_init() != 0) { STDERR_LOG("Could not initialize the server\n"); return 1; @@ -834,7 +841,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) && !defined(__OS2__) && !defined(__NETWARE__) +#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__) SetConsoleTitle(tw_server); #endif return -1; diff --git a/Server/module.c b/Server/module.c index 8ebd395..b04d912 100644 --- a/Server/module.c +++ b/Server/module.c @@ -17,7 +17,7 @@ extern struct tw_config config; -#if defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(__NeXT__) +#if defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(__NeXT__) || defined(__DOS__) void* tw_module_load(const char* path) { return NULL; } void* tw_module_symbol(void* mod, const char* sym) { return NULL; } diff --git a/Server/server.c b/Server/server.c index 7a42474..3ed89fe 100644 --- a/Server/server.c +++ b/Server/server.c @@ -47,7 +47,7 @@ typedef int socklen_t; #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) #ifndef NO_GETNAMEINFO #include #include @@ -70,6 +70,13 @@ typedef int socklen_t; #define htons(x) x #include "strptime.h" typedef int socklen_t; +#elif defined(__DOS__) +#include +#include +#include +#include + +#include "strptime.h" #else #ifdef USE_POLL #ifdef __PPU__ @@ -166,7 +173,7 @@ void close_socket(int sock) { int tw_server_init(void) { int i; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) WSADATA wsa; #ifdef USE_WINSOCK1 WSAStartup(MAKEWORD(1, 1), &wsa); @@ -964,6 +971,7 @@ cleanup: close_socket(sock); #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #ifdef __NETWARE__ +#elif defined(__DOS__) #else _endthread(); #endif @@ -986,6 +994,7 @@ struct thread_entry { thread_id thread; #elif defined(__NETWARE__) int thread; +#elif defined(__DOS__) #else HANDLE handle; #endif @@ -1075,6 +1084,8 @@ void tw_server_loop(void) { _beginthread(tw_server_pass, 0, 0, e); #elif defined(__NETWARE__) tw_server_pass(e); +#elif defined(__DOS__) + tw_server_pass(e); #else _beginthread(tw_server_pass, 0, e); #endif diff --git a/Server/strptime.c b/Server/strptime.c index 3148cc5..6277c2b 100644 --- a/Server/strptime.c +++ b/Server/strptime.c @@ -469,7 +469,7 @@ recurse: bp = NULL; continue; } -#if defined(_WIN32) || defined(__OS2__) || defined(__NeXT__) +#if defined(_WIN32) || defined(__OS2__) || defined(__NeXT__) || defined(__DOS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__NeXT__) if (1) #else diff --git a/Server/strptime.h b/Server/strptime.h index d69f07a..c565747 100644 --- a/Server/strptime.h +++ b/Server/strptime.h @@ -7,7 +7,7 @@ extern "C" { #include -#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) || defined(__NETWARE__) || defined(__NeXT__) +#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) || defined(__NETWARE__) || defined(__NeXT__) || defined(__DOS__) 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 579ee4d..f1f3dcb 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -17,7 +17,7 @@ extern "C" { #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) #ifdef USE_WINSOCK1 #include #else diff --git a/Server/version.c b/Server/version.c index 73e2de7..b38a060 100644 --- a/Server/version.c +++ b/Server/version.c @@ -21,6 +21,8 @@ const char* tw_platform = "NeXT" #elif defined(__NETWARE__) "NetWare" +#elif defined(__DOS__) + "DOS" #elif defined(__MINGW32__) "Windows-MinGW32" #elif defined(_MSC_VER) diff --git a/config_platform.h b/config_platform.h index fa20200..3d4d530 100644 --- a/config_platform.h +++ b/config_platform.h @@ -69,6 +69,10 @@ #define NO_IPV6 #endif +#if defined(__WATCOMC__) && defined(__DOS__) && !defined(NO_IPV6) +#define NO_IPV6 +#endif + #if defined(__NeXT__) && !defined(NO_IPV6) #define NO_IPV6 #endif -- 2.43.0