Index: /trunk/Common/Makefile
===================================================================
--- /trunk/Common/Makefile	(revision 214)
+++ /trunk/Common/Makefile	(revision 215)
@@ -4,4 +4,5 @@
 STATIC=a
 AR_FLAGS=rcs 
+AR_PROC=cat
 include $(PWD)/Platform/$(PLATFORM).mk
 
@@ -14,5 +15,5 @@
 
 common.$(STATIC): $(OBJS)
-	$(AR) $(AR_FLAGS)$@ $(OBJS)
+	$(AR) $(AR_FLAGS)$@ `echo $(OBJS) | $(AR_PROC)`
 
 .c.$(OBJ):
@@ -20,3 +21,3 @@
 
 clean:
-	rm -f *.o *.a *.lib
+	rm -f *.o *.a *.lib *.obj
Index: /trunk/Common/dir.c
===================================================================
--- /trunk/Common/dir.c	(revision 214)
+++ /trunk/Common/dir.c	(revision 215)
@@ -19,5 +19,5 @@
 
 char** cm_scandir(const char* path) {
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 	return NULL;
 #else
Index: /trunk/Module/Makefile
===================================================================
--- /trunk/Module/Makefile	(revision 214)
+++ /trunk/Module/Makefile	(revision 215)
@@ -14,6 +14,6 @@
 
 .c.$(OBJ):
-	$(CC) $(CFLAGS) -c -o $@ $<
+	$(CC) $(CFLAGS) -I ../Server -c -o $@ $<
 
 clean:
-	rm -f *.o *.so *.a *.dll *.dll
+	rm -f *.o *.so *.a *.dll
Index: /trunk/Module/mod_cgi.c
===================================================================
--- /trunk/Module/mod_cgi.c	(revision 214)
+++ /trunk/Module/mod_cgi.c	(revision 215)
@@ -1,5 +1,5 @@
 /* $Id$ */
 
-#include "../Server/tw_module.h"
+#include <tw_module.h>
 
 #include <cm_string.h>
Index: /trunk/Module/mod_example.c
===================================================================
--- /trunk/Module/mod_example.c	(revision 214)
+++ /trunk/Module/mod_example.c	(revision 215)
@@ -2,5 +2,5 @@
 /* This module will accept all directives, and always return 403 on the access. */
 
-#include "../Server/tw_module.h"
+#include <tw_module.h>
 
 int mod_init(struct tw_config* config, struct tw_tool* tools) {
Index: /trunk/Module/mod_proxy.c
===================================================================
--- /trunk/Module/mod_proxy.c	(revision 214)
+++ /trunk/Module/mod_proxy.c	(revision 215)
@@ -1,5 +1,5 @@
 /* $Id$ */
 
-#include "../Server/tw_module.h"
+#include <tw_module.h>
 
 #include <cm_string.h>
Index: /trunk/Platform/bcc.mk
===================================================================
--- /trunk/Platform/bcc.mk	(revision 215)
+++ /trunk/Platform/bcc.mk	(revision 215)
@@ -0,0 +1,16 @@
+# $Id$
+
+PREFIX = C:/Tewi
+
+CC = ../bcc.sh
+AR = tlib
+AR_FLAGS =
+AR_PROC = grep -Eo "[^ ]+" | xargs -I {} echo + {}
+CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
+LDFLAGS =
+LIBS = -lws2_32
+EXEC =
+STATIC = lib
+LIBSUF = .dll
+OBJ = obj
+REQOBJS = tewi_bcc.res
Index: /trunk/Platform/vc6.mk
===================================================================
--- /trunk/Platform/vc6.mk	(revision 214)
+++ /trunk/Platform/vc6.mk	(revision 215)
@@ -13,2 +13,3 @@
 LIBSUF = .dll
 OBJ = obj
+PREOBJS = tewi_vc6.res
Index: /trunk/Server/Makefile
===================================================================
--- /trunk/Server/Makefile	(revision 214)
+++ /trunk/Server/Makefile	(revision 215)
@@ -14,5 +14,5 @@
 tewi_strip$(EXEC): tewi$(EXEC)
 
-tewi$(EXEC): $(OBJS) ../Common/common.$(STATIC)
+tewi$(EXEC): $(OBJS) ../Common/common.$(STATIC) $(REQOBJS)
 	$(CC) $(LDFLAGS) $(EXTLDFLAGS) -o $@ $(OBJS) $(EXTLIBS) ../Common/common.$(STATIC) $(LIBS)
 	$(SERVADD)
@@ -49,4 +49,10 @@
 	$(WINDRES) tewi.rc -O coff -o $@
 
+tewi_vc6.res: tewi.rc ../Binary/tewi.ico
+	rc /fo$@ tewi.rc
+
+tewi_bcc.res: tewi.rc ../Binary/tewi.ico
+	brc32 -r -fo$@ tewi.rc
+
 clean:
 	rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj
Index: /trunk/Server/config.c
===================================================================
--- /trunk/Server/config.c	(revision 214)
+++ /trunk/Server/config.c	(revision 215)
@@ -11,9 +11,9 @@
 #include <string.h>
 
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <unistd.h>
 #endif
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #include <winsock2.h>
 #endif
@@ -267,5 +267,5 @@
 					) {
 						for(i = 1; r[i] != NULL; i++) {
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 							uint32_t port = atoi(r[i]);
 #else
@@ -274,5 +274,5 @@
 							int j;
 							cm_log("Config", "Going to listen at port %d%s", (int)port, cm_strcaseequ(r[0], "ListenSSL") ? " with SSL" : "");
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 							if(cm_strcaseequ(r[0], "ListenSSL")) port |= (1UL << 31);
 #else
Index: /trunk/Server/http.c
===================================================================
--- /trunk/Server/http.c	(revision 214)
+++ /trunk/Server/http.c	(revision 215)
@@ -16,5 +16,5 @@
 #include <string.h>
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #include <winsock2.h>
 #else
Index: /trunk/Server/main.c
===================================================================
--- /trunk/Server/main.c	(revision 214)
+++ /trunk/Server/main.c	(revision 215)
@@ -5,5 +5,11 @@
 #include "../config.h"
 
-#ifndef _MSC_VER
+#ifdef __BORLANDC__
+
+#pragma resource "tewi_bcc.res"
+
+#endif
+
+#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <unistd.h>
 #endif
@@ -25,5 +31,5 @@
 #include "tw_version.h"
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #include <windows.h>
 #endif
@@ -62,5 +68,5 @@
 #define printf(...) tt_printf(__VA_ARGS__)
 #define STDERR_LOG(...) tt_printf(__VA_ARGS__)
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__BORLANDC__)
 void STDERR_LOG(const char* format, ...) {
 	va_list args;
@@ -784,5 +790,5 @@
 	cm_force_log(r);
 	free(r);
-#if !defined(__MINGW32__) && !defined(_MSC_VER)
+#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__)
 	signal(SIGCHLD, SIG_IGN);
 	signal(SIGPIPE, SIG_IGN);
Index: /trunk/Server/module.c
===================================================================
--- /trunk/Server/module.c	(revision 214)
+++ /trunk/Server/module.c	(revision 215)
@@ -12,5 +12,5 @@
 #include <string.h>
 #include <stdlib.h>
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <unistd.h>
 #endif
@@ -27,5 +27,5 @@
 #else
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #include <windows.h>
 #else
@@ -37,5 +37,5 @@
 	void* lib;
 	chdir(config.server_root);
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 	lib = LoadLibraryA(path);
 #else
@@ -51,5 +51,5 @@
 
 void* tw_module_symbol(void* mod, const char* sym) {
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 	return GetProcAddress(mod, sym);
 #else
Index: /trunk/Server/server.c
===================================================================
--- /trunk/Server/server.c	(revision 214)
+++ /trunk/Server/server.c	(revision 215)
@@ -16,5 +16,5 @@
 #include "tw_version.h"
 
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__BORLANDC__)
 #include <unistd.h>
 #endif
@@ -33,5 +33,5 @@
 #include <cm_dir.h>
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #ifndef NO_GETADDRINFO
 #include <ws2tcpip.h>
@@ -84,5 +84,5 @@
 int sockets[MAX_PORTS];
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 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,5 +111,5 @@
 
 void close_socket(int sock) {
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 	closesocket(sock);
 #else
@@ -120,5 +120,5 @@
 int tw_server_init(void) {
 	int i;
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 	WSADATA wsa;
 	WSAStartup(MAKEWORD(2, 0), &wsa);
@@ -135,5 +135,5 @@
 		int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
 #endif
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 		if(sock == INVALID_SOCKET)
 #else
@@ -238,5 +238,5 @@
 		doc = NULL;
 	}
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 	sprintf(construct, "%lu", (unsigned long)size);
 #else
@@ -451,4 +451,6 @@
 #if defined(__MINGW32__) || defined(_MSC_VER)
 unsigned int WINAPI tw_server_pass(void* ptr) {
+#elif defined(__BORLANDC__)
+void tw_server_pass(void* ptr) {
 #elif defined(__HAIKU__)
 int32_t tw_server_pass(void* ptr) {
@@ -456,5 +458,5 @@
 int tw_server_pass(void* ptr) {
 #endif
-#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER)
+#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #define FREE_PTR
 	int sock = ((struct pass_entry*)ptr)->sock;
@@ -549,5 +551,5 @@
 					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)
+#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__)
 					t = 0;
 					btm = localtime(&t);
@@ -612,8 +614,18 @@
 			char* rpath;
 			struct stat st;
+			char* slash;
 			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(__MINGW32__) || defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+			for(i = strlen(path) - 1; i >= 0; i--){
+				if(path[i] == '/'){
+					path[i] = 0;
+				}else{
+					break;
+				}
+			}
+#endif
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 			rpath = cm_strdup(path);
 			for(i = strlen(rpath) - 1; i >= 0; i--) {
@@ -647,5 +659,6 @@
 				} else if(S_ISDIR(st.st_mode)) {
 					if(req.path[strlen(req.path) - 1] != '/') {
-						char* headers[3] = {"Location", cm_strcat(req.path, "/"), NULL};
+						char* headers[3] = {"Location", NULL, NULL};
+						headers[1] = cm_strcat(req.path, "/");
 						cm_log("Server", "Accessing directory without the slash at the end");
 						_tw_process_page(s, sock, tw_http_status(301), NULL, NULL, NULL, 0, headers, 0, 0);
@@ -885,10 +898,16 @@
 #endif
 	close_socket(sock);
-#if defined(__MINGW32__) || defined(_MSC_VER)
-	_endthread(0);
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
+	_endthread(
+#ifndef __BORLANDC__
+		0
+#endif
+	);
 #elif defined(__HAIKU__)
 		exit_thread(0);
 #endif
+#ifndef __BORLANDC__
 	return 0;
+#endif
 }
 
@@ -898,5 +917,5 @@
 #endif
 
-#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__)
 struct thread_entry {
 #ifdef __HAIKU__
@@ -917,5 +936,5 @@
 	struct timeval tv;
 #endif
-#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__)
 	struct thread_entry threads[2048];
 	for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) {
@@ -948,5 +967,5 @@
 #endif
 		if(ret == -1) {
-#if !defined(__MINGW32__) && !defined(_MSC_VER)
+#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__)
 			cm_log("Server", "Select failure: %s", strerror(errno));
 #endif
@@ -972,10 +991,10 @@
 					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)
+#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__)
 					int j;
 					struct pass_entry* e = malloc(sizeof(*e));
 					cm_log("Server", "New connection accepted");
 					e->sock = sock;
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 					e->ssl = config.ports[i] & (1UL << 31);
 #else
@@ -985,5 +1004,5 @@
 					e->addr = claddr;
 #endif
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 					_beginthread(tw_server_pass, 0, e);
 #elif defined(_PSP) || defined(__PPU__)
Index: /trunk/Server/strptime.c
===================================================================
--- /trunk/Server/strptime.c	(revision 214)
+++ /trunk/Server/strptime.c	(revision 215)
@@ -36,5 +36,5 @@
 //__RCSID("$NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $");
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 
 #include <ctype.h>
@@ -104,7 +104,28 @@
 #define isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define tzname              _tzname
 #define strncasecmp         _strnicmp
+#endif
+
+#ifdef __BORLANDC__
+char* cm_strdup(const char* str);
+
+int _strnicmp(const char* _a, const char* _b, int len){
+	char* a = cm_strdup(_a);
+	char* b = cm_strdup(_b);
+	int i;
+	char* r;
+	for(i = 0; a[i] != 0; i++){
+		a[i] = tolower(a[i]);
+	}
+	for(i = 0; b[i] != 0; i++){
+		b[i] = tolower(b[i]);
+	}
+	r = strncmp(a, b, len);
+	free(a);
+	free(b);
+	return r;
+}
 #endif
 
@@ -400,5 +421,5 @@
 
 #ifndef TIME_MAX
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define TIME_MAX	INT32_MAX
 #else
@@ -409,5 +430,5 @@
             {
                 time_t sse = 0;
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
                 uint32_t rulim = TIME_MAX;
 #else
@@ -426,5 +447,5 @@
                 } while ((sse * 10 <= TIME_MAX) &&
                      rulim && *bp >= '0' && *bp <= '9');
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
                 if (sse < 0 || (uint32_t)sse > TIME_MAX) {
 #else
@@ -435,5 +456,5 @@
                 }
 #ifdef _WIN32
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 		if (1)
 #else
Index: /trunk/Server/tw_config.h
===================================================================
--- /trunk/Server/tw_config.h	(revision 214)
+++ /trunk/Server/tw_config.h	(revision 215)
@@ -15,5 +15,5 @@
 #include <stdbool.h>
 
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
 #include <winsock2.h>
 #define NO_IPV6
@@ -43,5 +43,5 @@
 #define MAX_README 8
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define NUM1024 1024UL
 #else
@@ -95,5 +95,5 @@
 
 struct tw_config {
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 	uint32_t ports[MAX_PORTS + 1];
 #else
Index: /trunk/Server/version.c
===================================================================
--- /trunk/Server/version.c	(revision 214)
+++ /trunk/Server/version.c	(revision 215)
@@ -18,4 +18,6 @@
 #elif defined(_MSC_VER)
     "Windows-MSVC"
+#elif defined(__BORLANDC__)
+    "Windows-BCC"
 #elif defined(__HAIKU__)
     "Haiku"
Index: /trunk/bcc.sh
===================================================================
--- /trunk/bcc.sh	(revision 215)
+++ /trunk/bcc.sh	(revision 215)
@@ -0,0 +1,55 @@
+#!/bin/sh
+# $Id$
+# Wrapper for CL. VC6 sucks.
+
+outfile="a.out"
+dowhat=""
+options="-I../VC6Compat -tWM"
+obj=0
+source=""
+libraries=""
+link=""
+shared=0
+
+for i in "$@"; do
+	if [ "$i" = "-o" ]; then
+		dowhat="output"
+	elif [ "$i" = "-I" ]; then
+		dowhat="include"
+	elif [ "$i" = "-c" ]; then
+		options="$options -c"
+		obj=1
+	elif [ "$i" = "-fPIC" ]; then
+		:
+	elif [ "$i" = "-g" ]; then
+		:
+	elif [ "$i" = "-std=c99" ]; then
+		:
+	elif [ "$i" = "-shared" ]; then
+		options="$options -tWD"
+		shared=1
+	elif [ "`echo "$i" | grep -Eo "^-D"`" = "-D" ]; then
+		options="$options -`echo "$i" | sed "s/^-//g"`"
+	elif [ "`echo "$i" | grep -Eo "^-l"`" = "-l" ]; then
+		libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib"
+	elif [ "$dowhat" = "output" ]; then
+		dowhat=""
+		outfile="$i"
+	elif [ "$dowhat" = "include" ]; then
+		dowhat=""
+		options="$options -I$i"
+	elif [ ! "`echo "$i" | grep -Eo "^."`" = "-" ]; then
+		source="$source $i"
+	fi
+done
+if [ "$obj" = "1" ]; then
+	options="$options -o$outfile"
+else
+	options="$options -e$outfile"
+fi
+if [ ! "$libraries" = "" ]; then
+	link="$libraries"
+fi
+construct="bcc32 $options $source $link"
+echo "Run: $construct"
+$construct
Index: /trunk/config.h.tmpl
===================================================================
--- /trunk/config.h.tmpl	(revision 214)
+++ /trunk/config.h.tmpl	(revision 215)
@@ -18,15 +18,15 @@
 #endif
 
-#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(USE_POLL)
+#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)) && defined(USE_POLL)
 #undef USE_POLL
 /* Force select(2) for Windows */
 #endif
 
-#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(HAS_CHROOT)
+#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)) && defined(HAS_CHROOT)
 #undef HAS_CHROOT
 /* Windows should not have chroot */
 #endif
 
-#if defined(_MSC_VER) && !defined(NO_GETADDRINFO)
+#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(NO_GETADDRINFO)
 #define NO_GETADDRINFO
 /* Do not use getaddrinfo */
