Index: trunk/Server/Makefile
===================================================================
--- trunk/Server/Makefile	(revision 314)
+++ trunk/Server/Makefile	(revision 315)
@@ -60,3 +60,3 @@
 
 clean:
-	rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc *.tds
+	rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc *.tds *.nlm
Index: trunk/Server/config.c
===================================================================
--- trunk/Server/config.c	(revision 314)
+++ trunk/Server/config.c	(revision 315)
@@ -10,4 +10,5 @@
 #include <string.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 #if !defined(_MSC_VER) && !defined(__BORLANDC__)
@@ -125,4 +126,6 @@
 #elif defined(__ps2sdk__)
 	strcpy(config.hostname, "ps2");
+#elif defined(__NETWARE__)
+	strcpy(config.hostname, "netware");
 #else
 	gethostname(config.hostname, 1024);
@@ -584,4 +587,5 @@
 		}
 	} else {
+		printf("%d\n", errno);
 		cm_log("Config", "Could not open the file");
 		return 1;
Index: trunk/Server/http.c
===================================================================
--- trunk/Server/http.c	(revision 314)
+++ trunk/Server/http.c	(revision 315)
@@ -22,5 +22,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(__NETWARE__))
 #ifdef USE_WINSOCK1
 #include <winsock.h>
@@ -28,4 +28,6 @@
 #include <winsock2.h>
 #endif
+#elif defined(__NETWARE__)
+#include <sys/socket.h>
 #else
 #ifdef USE_POLL
Index: trunk/Server/main.c
===================================================================
--- trunk/Server/main.c	(revision 314)
+++ trunk/Server/main.c	(revision 315)
@@ -35,6 +35,9 @@
 #include "tw_version.h"
 
-#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(__NETWARE__))
 #include <windows.h>
+#elif defined(__NETWARE__)
+#include <nwconio.h>
+#include <nwthread.h>
 #endif
 
@@ -93,5 +96,5 @@
 int startup(int argc, char** argv);
 
-#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__)) || defined(__BORLANDC__)
+#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__)
 char* get_registry(const char* main, const char* sub) {
 	DWORD bufsize = 512;
@@ -533,6 +536,30 @@
 
 #if !defined(BUILD_GUI_VALID)
+void thread_stuff(void* pargs);
+
+struct arg_struct {
+	int argc;
+	char** argv;
+};
+
 int main(int argc, char** argv) {
 	int st;
+#ifdef __NETWARE__
+	struct arg_struct* parg = malloc(sizeof(*parg));
+	parg->argc = argc;
+	parg->argv = argv;
+	DestroyScreen(GetCurrentScreen());
+	SetCurrentScreen(CreateScreen("Tewi Console", 0));
+	BeginThread(thread_stuff, NULL, 0, parg);
+	ThreadSwitch();
+	ExitThread(EXIT_THREAD, 0);
+	return 0;
+}
+
+void thread_stuff(void* pargs) {
+	int st;
+	int argc = ((struct arg_struct*)pargs)->argc;
+	char** argv = ((struct arg_struct*)pargs)->argv;
+#endif
 #ifdef SERVICE
 	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
@@ -707,5 +734,9 @@
 			;
 #endif
+#ifdef __NETWARE__
+		return;
+#else
 		return st;
+#endif
 #endif
 	}
@@ -715,5 +746,9 @@
 	sceKernelExitGame();
 #endif
+#ifdef __NETWARE__
+	return;
+#else
 	return 0;
+#endif
 }
 #endif
@@ -722,5 +757,5 @@
 	int i;
 	char* r;
-#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__)) || defined(__BORLANDC__)
+#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__)
 	char* confpath = cm_strdup(PREFIX "/etc/tewi.conf");
 	char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
@@ -806,5 +841,5 @@
 	signal(SIGCHLD, SIG_IGN);
 	signal(SIGPIPE, SIG_IGN);
-#elif !defined(BUILD_GUI) && !defined(__OS2__)
+#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__)
 	SetConsoleTitle(tw_server);
 #endif
Index: trunk/Server/module.c
===================================================================
--- trunk/Server/module.c	(revision 314)
+++ trunk/Server/module.c	(revision 315)
@@ -32,4 +32,7 @@
 #define INCL_DOSERRORS
 #include <os2.h>
+#elif defined(__NETWARE__)
+#include <nwadv.h>
+#include <nwthread.h>
 #else
 #include <windows.h>
@@ -46,12 +49,17 @@
 #ifdef __OS2__
 	HMODULE mod;
+#elif defined(__NETWARE__)
+	unsigned int* hnd = malloc(sizeof(*hnd));
 #endif
 	chdir(config.server_root);
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 #ifdef __OS2__
-	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR){
+	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) {
 		return NULL;
 	}
 	lib = (void*)mod;
+#elif defined(__NETWARE__)
+	*hnd = FindNLMHandle(path);
+	lib = (void*)hnd;
 #else
 	lib = LoadLibraryA(path);
@@ -73,9 +81,11 @@
 	void* ret;
 	APIRET rc;
-	if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR){
+	if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR) {
 		cm_log("Module", "OS/2 error %d", (int)rc);
 		return NULL;
 	}
 	return ret;
+#elif defined(__NETWARE__)
+	return ImportSymbol(*(unsigned int*)mod, sym);
 #else
 	return GetProcAddress(mod, sym);
Index: trunk/Server/server.c
===================================================================
--- trunk/Server/server.c	(revision 314)
+++ trunk/Server/server.c	(revision 315)
@@ -48,5 +48,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(__NETWARE__))
 #ifndef NO_GETNAMEINFO
 #include <ws2tcpip.h>
@@ -63,4 +63,13 @@
 #include "strptime.h"
 typedef int socklen_t;
+#elif defined(__NETWARE__)
+#include <sys/socket.h>
+#include <nwthread.h>
+
+typedef int socklen_t;
+#define IPPROTO_TCP 0
+#define INADDR_ANY 0
+#define htons(x) x
+#include "strptime.h"
 #else
 #ifdef USE_POLL
@@ -137,4 +146,6 @@
 #ifdef __OS2__
 	soclose(sock);
+#elif defined(__NETWARE__)
+	shutdown(sock, 2);
 #elif defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 	closesocket(sock);
@@ -146,5 +157,5 @@
 int tw_server_init(void) {
 	int i;
-#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(__NETWARE__))
 	WSADATA wsa;
 #ifdef USE_WINSOCK1
@@ -522,8 +533,10 @@
 	struct sockaddr* sa = (struct sockaddr*)&addr;
 	getnameinfo(sa, sizeof(addr), address, 512, NULL, 0, NI_NUMERICHOST);
-#else
-		addrstr = inet_ntoa(addr.sin_addr);
-		strcpy(address, addrstr);
-		address[strlen(addrstr)] = 0;
+#elif defined(__NETWARE__)
+		address[0] = 0;
+#else
+	addrstr = inet_ntoa(addr.sin_addr);
+	strcpy(address, addrstr);
+	address[strlen(addrstr)] = 0;
 #endif
 #ifdef FREE_PTR
@@ -632,5 +645,5 @@
 			tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "MOD_REQUEST");
 #else
-			tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "mod_request");
+				tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "mod_request");
 #endif
 			if(mod_req != NULL) {
@@ -941,5 +954,9 @@
 	close_socket(sock);
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __NETWARE__
+	ExitThread(EXIT_THREAD, 0);
+#else
 	_endthread();
+#endif
 #elif defined(__HAIKU__)
 		exit_thread(0);
@@ -959,4 +976,6 @@
 #ifdef __HAIKU__
 	thread_id thread;
+#elif defined(__NETWARE__)
+	int thread;
 #else
 	HANDLE handle;
@@ -1046,4 +1065,6 @@
 #ifdef __OS2__
 					_beginthread(tw_server_pass, 0, 0, e);
+#elif defined(__NETWARE__)
+					BeginThread(tw_server_pass, 0, 0, e);
 #else
 					_beginthread(tw_server_pass, 0, e);
Index: trunk/Server/strptime.c
===================================================================
--- trunk/Server/strptime.c	(revision 314)
+++ trunk/Server/strptime.c	(revision 315)
@@ -38,4 +38,5 @@
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 
+#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
@@ -44,5 +45,7 @@
 
 #ifdef __WATCOMC__
+#ifndef __NETWARE__
 #include <strings.h>
+#endif
 #endif
 
@@ -117,6 +120,10 @@
 #endif
 
-#ifdef __BORLANDC__
+#if defined(__BORLANDC__) || defined(__NETWARE__)
 char* cm_strdup(const char* str);
+
+#ifdef __NETWARE__
+#define strncasecmp _strnicmp
+#endif
 
 int _strnicmp(const char* _a, const char* _b, int len){
@@ -124,5 +131,5 @@
 	char* b = cm_strdup(_b);
 	int i;
-	char* r;
+	int r;
 	for(i = 0; a[i] != 0; i++){
 		a[i] = tolower(a[i]);
@@ -429,5 +436,5 @@
 
 #ifndef TIME_MAX
-#if defined(_MSC_VER) || defined(__BORLANDC__)
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__NETWARE__)
 #define TIME_MAX	INT32_MAX
 #else
Index: trunk/Server/strptime.h
===================================================================
--- trunk/Server/strptime.h	(revision 314)
+++ trunk/Server/strptime.h	(revision 315)
@@ -8,5 +8,5 @@
 #include <time.h>
 
-#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__)
+#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) || defined(__NETWARE__)
 char* strptime(const char *buf, const char *fmt, struct tm *tm);
 #endif
Index: trunk/Server/tw_config.h
===================================================================
--- trunk/Server/tw_config.h	(revision 314)
+++ trunk/Server/tw_config.h	(revision 315)
@@ -15,5 +15,5 @@
 #include <stdbool.h>
 
-#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(__NETWARE__))
 #ifdef USE_WINSOCK1
 #include <winsock.h>
@@ -26,5 +26,5 @@
 #include <net/net.h>
 #endif
-#if !defined(__OS2__)
+#if !defined(__OS2__) && !defined(__NETWARE__)
 #include <netinet/in.h>
 #endif
@@ -32,4 +32,17 @@
 #define NO_IPV6
 #endif
+#endif
+
+#ifdef __NETWARE__
+struct in_addr {
+	unsigned int s_addr;
+};
+
+struct sockaddr_in {
+	unsigned short sin_family;
+	unsigned short sin_port;
+	struct in_addr sin_addr;
+	char sin_zero[8];
+};
 #endif
 
Index: trunk/Server/tw_module.h
===================================================================
--- trunk/Server/tw_module.h	(revision 314)
+++ trunk/Server/tw_module.h	(revision 315)
@@ -16,4 +16,6 @@
 #include <os2.h>
 #define MODULE_DECL __export APIENTRY
+#elif defined(__WATCOMC__)
+#define MODULE_DECL __export
 #else
 #define MODULE_DECL
@@ -47,7 +49,7 @@
 #define TW_CONFIG_ERROR _TW_CONFIG_ERROR
 
-typedef int (MODULE_DECL *tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
-typedef int (MODULE_DECL *tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
-typedef int (MODULE_DECL *tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc);
+typedef int(MODULE_DECL* tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
+typedef int(MODULE_DECL* tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
+typedef int(MODULE_DECL* tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc);
 
 #ifdef SOURCE
