Index: /trunk/Makefile
===================================================================
--- /trunk/Makefile	(revision 311)
+++ /trunk/Makefile	(revision 312)
@@ -44,5 +44,7 @@
 	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:
Index: /trunk/Platform/os2.mk
===================================================================
--- /trunk/Platform/os2.mk	(revision 311)
+++ /trunk/Platform/os2.mk	(revision 312)
@@ -7,5 +7,5 @@
 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 =
@@ -14,4 +14,2 @@
 LIBSUF = .dll
 OBJ = obj
-REQOBJS = concat.rc
-SERVADD = wrc -bt=nt -i=$(WATCOM)/h/nt concat.rc tewi.exe
Index: /trunk/Server/config.c
===================================================================
--- /trunk/Server/config.c	(revision 311)
+++ /trunk/Server/config.c	(revision 312)
@@ -3,6 +3,5 @@
 #define SOURCE
 
-#include "tw_config.h"
-#include "tw_module.h"
+#include "../config.h"
 
 #include <stdio.h>
@@ -16,5 +15,5 @@
 #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 <winsock.h>
@@ -26,4 +25,13 @@
 #include <cm_string.h>
 #include <cm_log.h>
+
+#ifdef __OS2__
+#include <types.h>
+#include <netinet/in.h>
+#include <tcpustd.h>
+#endif
+
+#include "tw_config.h"
+#include "tw_module.h"
 
 struct tw_config config;
Index: /trunk/Server/http.c
===================================================================
--- /trunk/Server/http.c	(revision 311)
+++ /trunk/Server/http.c	(revision 312)
@@ -16,5 +16,11 @@
 #include <string.h>
 
-#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+#include <sys/time.h>
+#include <types.h>
+#include <tcpustd.h>
+#endif
+
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
 #ifdef USE_WINSOCK1
 #include <winsock.h>
Index: /trunk/Server/main.c
===================================================================
--- /trunk/Server/main.c	(revision 311)
+++ /trunk/Server/main.c	(revision 312)
@@ -22,4 +22,8 @@
 #ifndef NO_SSL
 #include <openssl/opensslv.h>
+#endif
+
+#ifdef __OS2__
+#include <types.h>
 #endif
 
@@ -802,5 +806,5 @@
 	signal(SIGCHLD, SIG_IGN);
 	signal(SIGPIPE, SIG_IGN);
-#elif !defined(BUILD_GUI)
+#elif !defined(BUILD_GUI) && !defined(__OS2__)
 	SetConsoleTitle(tw_server);
 #endif
Index: /trunk/Server/module.c
===================================================================
--- /trunk/Server/module.c	(revision 311)
+++ /trunk/Server/module.c	(revision 312)
@@ -28,6 +28,11 @@
 
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+#define INCL_DOSMODULEMGR
+#include <os2.h>
+#else
 #include <windows.h>
 #include <direct.h>
+#endif
 #else
 #include <dlfcn.h>
@@ -37,7 +42,15 @@
 	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);
@@ -53,5 +66,11 @@
 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);
Index: /trunk/Server/server.c
===================================================================
--- /trunk/Server/server.c	(revision 311)
+++ /trunk/Server/server.c	(revision 312)
@@ -19,4 +19,5 @@
 #include <unistd.h>
 #endif
+#include <ctype.h>
 #include <string.h>
 #include <stdbool.h>
@@ -33,4 +34,18 @@
 #include <cm_dir.h>
 
+#ifdef __OS2__
+#include <types.h>
+#include <sys/time.h>
+#define INCL_DOSPROCESS
+#include <os2.h>
+#include <process.h>
+#define HANDLE void*
+
+#include "strptime.h"
+typedef int socklen_t;
+
+#include <tcpustd.h>
+#endif
+
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
 #ifndef NO_GETNAMEINFO
@@ -109,5 +124,5 @@
 		} 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++;
@@ -120,5 +135,7 @@
 
 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
@@ -129,5 +146,5 @@
 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
@@ -136,4 +153,7 @@
 	WSAStartup(MAKEWORD(2, 0), &wsa);
 #endif
+#endif
+#ifdef __OS2__
+	sock_init();
 #endif
 	for(i = 0; config.ports[i] != -1; i++)
@@ -1020,5 +1040,9 @@
 #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);
Index: /trunk/Server/strptime.c
===================================================================
--- /trunk/Server/strptime.c	(revision 311)
+++ /trunk/Server/strptime.c	(revision 312)
@@ -463,5 +463,5 @@
                     continue;
                 }
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__OS2__)
 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 		if (1)
Index: /trunk/Server/strptime.h
===================================================================
--- /trunk/Server/strptime.h	(revision 311)
+++ /trunk/Server/strptime.h	(revision 312)
@@ -8,5 +8,5 @@
 #include <time.h>
 
-#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
Index: /trunk/Server/tw_config.h
===================================================================
--- /trunk/Server/tw_config.h	(revision 311)
+++ /trunk/Server/tw_config.h	(revision 312)
@@ -26,5 +26,7 @@
 #include <net/net.h>
 #endif
+#if !defined(__OS2__)
 #include <netinet/in.h>
+#endif
 #ifdef __HAIKU__
 #define NO_IPV6
@@ -32,5 +34,5 @@
 #endif
 
-#ifdef NO_IPV6
+#if defined(NO_IPV6)
 #define SOCKADDR struct sockaddr_in
 #else
Index: /trunk/Server/version.c
===================================================================
--- /trunk/Server/version.c	(revision 311)
+++ /trunk/Server/version.c	(revision 312)
@@ -16,4 +16,6 @@
 #elif defined(__linux__)
     "Linux"
+#elif defined(__OS2__)
+    "OS/2"
 #elif defined(__MINGW32__)
     "Windows-MinGW32"
Index: /trunk/config.h.tmpl
===================================================================
--- /trunk/config.h.tmpl	(revision 311)
+++ /trunk/config.h.tmpl	(revision 312)
@@ -69,4 +69,8 @@
 #endif
 
+#if defined(__WATCOMC__) && defined(__OS2__) && !defined(NO_IPV6)
+#define NO_IPV6
+#endif
+
 #endif
 
