Index: trunk/Makefile
===================================================================
--- trunk/Makefile	(revision 155)
+++ trunk/Makefile	(revision 156)
@@ -9,5 +9,5 @@
 FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX)
 
-.PHONY: all format clean ./Server ./Common ./Module ./Manpage get-version
+.PHONY: all format clean ./Server ./Common ./Module get-version
 
 all: ./Server ./Module ./Manpage ./Tool/genconf ./Tool/itworks
@@ -31,8 +31,5 @@
 	$(MAKE) -C $@ $(FLAGS)
 
-./Manpage::
-	$(MAKE) -C $@ $(FLAGS)
-
-./README: ./README.tmpl
+./README: ./README.tmpl ./Server/tw_version.h
 	sed "s/@VERSION@/`grep "define TW_VERSION" Server/tw_version.h | grep -Eo '"[^\]+' | sed -E 's/^"//g'`/g" ./README.tmpl > $@
 
@@ -44,5 +41,4 @@
 	cp ./Server/tewi $(PREFIX)/bin/
 	cp ./Module/*.so $(PREFIX)/lib/tewi/
-	cp ./Manpage/tewi.8 $(PREFIX)/share/man/man8/
 
 format:
@@ -56,4 +52,3 @@
 	$(MAKE) -C ./Module $(FLAGS) clean
 	$(MAKE) -C ./Common $(FLAGS) clean
-	$(MAKE) -C ./Manpage $(FLAGS) clean
 	rm -f ./Tool/option ./Tool/genconf
Index: trunk/README
===================================================================
--- trunk/README	(revision 155)
+++ trunk/README	(revision 156)
@@ -1,4 +1,4 @@
 
-Tewi HTTPd version 1.06C
+Tewi HTTPd version 1.07
 
 Original by Nishi <nishi@nishi.boats>
Index: trunk/Server/config.c
===================================================================
--- trunk/Server/config.c	(revision 155)
+++ trunk/Server/config.c	(revision 156)
@@ -73,10 +73,17 @@
 	}
 	for(i = 0; i < MAX_VHOSTS; i++) {
+#ifndef NO_SSL
 		config.vhosts[i].sslkey = NULL;
 		config.vhosts[i].sslcert = NULL;
+#endif
 		config.vhosts[i].root = NULL;
-	}
+#ifdef HAS_CHROOT
+		config.vhosts[i].chroot_path = NULL;
+#endif
+	}
+#ifndef NO_SSL
 	config.root.sslkey = NULL;
 	config.root.sslcert = NULL;
+#endif
 	config.root.root = NULL;
 	config.root.mime_count = 0;
@@ -86,4 +93,7 @@
 	config.root.readme_count = 0;
 	config.root.hideport = 0;
+#ifdef HAS_CHROOT
+	config.root.chroot_path = NULL;
+#endif
 	config.vhost_count = 0;
 	config.module_count = 0;
@@ -91,4 +101,5 @@
 	config.server_root = cm_strdup(PREFIX);
 	config.server_admin = cm_strdup(SERVER_ADMIN);
+	config.defined[0] = NULL;
 	gethostname(config.hostname, 1024);
 }
@@ -99,4 +110,6 @@
 	cbuf[1] = 0;
 	int ln = 0;
+	int ifbr = 0;
+	int ignore = -1;
 	FILE* f = fopen(path, "r");
 	if(f != NULL) {
@@ -115,5 +128,10 @@
 					char** r = cm_split(l, " \t");
 					int i;
-					if(cm_strcaseequ(r[0], "Include") || cm_strcaseequ(r[0], "IncludeOptional")) {
+					if(ignore != -1 && ifbr >= ignore) {
+						if(cm_strcaseequ(r[0], "EndIf")) ifbr--;
+						if(ifbr == 0) {
+							ignore = -1;
+						}
+					} else if(cm_strcaseequ(r[0], "Include") || cm_strcaseequ(r[0], "IncludeOptional")) {
 						for(i = 1; r[i] != NULL; i++) {
 							if(tw_config_read(r[i]) != 0 && cm_strcaseequ(r[0], "Include")) {
@@ -121,4 +139,18 @@
 								break;
 							}
+						}
+					} else if(cm_strcaseequ(r[0], "Define")) {
+						if(r[1] == NULL) {
+							cm_log("Config", "Missing name at line %d", ln);
+							stop = 1;
+						} else {
+							tw_add_define(r[1]);
+						}
+					} else if(cm_strcaseequ(r[0], "Undefine")) {
+						if(r[1] == NULL) {
+							cm_log("Config", "Missing name at line %d", ln);
+							stop = 1;
+						} else {
+							tw_delete_define(r[1]);
 						}
 					} else if(cm_strcaseequ(r[0], "BeginDirectory")) {
@@ -224,4 +256,5 @@
 					} else if(cm_strcaseequ(r[0], "ShowPort")) {
 						current->hideport = 0;
+#ifndef NO_SSL
 					} else if(cm_strcaseequ(r[0], "SSLKey")) {
 						if(r[1] == NULL) {
@@ -239,4 +272,53 @@
 							if(current->sslcert != NULL) free(current->sslcert);
 							current->sslcert = cm_strdup(r[1]);
+						}
+#endif
+					} else if(cm_strcaseequ(r[0], "ForceLog")) {
+						if(r[1] == NULL) {
+							cm_log("Config", "Missing log at line %d", ln);
+							stop = 1;
+						} else {
+							cm_force_log(r[1]);
+						}
+					} else if(cm_strcaseequ(r[0], "EndIf")) {
+						if(ifbr == 0) {
+							cm_log("Config", "Missing BeginIf at line %d", ln);
+							stop = 1;
+						}
+						ifbr--;
+					} else if(cm_strcaseequ(r[0], "BeginIf") || cm_strcaseequ(r[0], "BeginIfNot")) {
+						if(r[1] == NULL) {
+							cm_log("Config", "Missing condition type at line %d", ln);
+						} else {
+							ifbr++;
+							bool ign = false;
+							if(cm_strcaseequ(r[1], "False")) {
+								ign = true;
+							} else if(cm_strcaseequ(r[1], "True")) {
+							} else if(cm_strcaseequ(r[1], "Defined")) {
+								if(r[2] == NULL) {
+									cm_log("Config", "Missing name at line %d", ln);
+									stop = 1;
+								} else {
+									int i;
+									bool fndit = false;
+									for(i = 0; config.defined[i] != NULL; i++) {
+										if(strcmp(config.defined[i], r[2]) == 0) {
+											fndit = true;
+											break;
+										}
+									}
+									if(!fndit) {
+										ign = true;
+									}
+								}
+							} else {
+								cm_log("Config", "Unknown condition type at line %d", ln);
+								stop = 1;
+							}
+							if(cm_strcaseequ(r[0], "BeginIfNot")) ign = !ign;
+							if(ign) {
+								ignore = ifbr - 1;
+							}
 						}
 					} else if(cm_strcaseequ(r[0], "ServerRoot")) {
Index: trunk/Server/module.c
===================================================================
--- trunk/Server/module.c	(revision 155)
+++ trunk/Server/module.c	(revision 156)
@@ -10,4 +10,5 @@
 #include <cm_log.h>
 
+#include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -56,7 +57,28 @@
 }
 
+void tw_add_define(const char* string) {
+	int i;
+	for(i = 0; config.defined[i] != NULL; i++)
+		;
+	config.defined[i] = cm_strdup(string);
+	config.defined[i + 1] = NULL;
+}
+
+void tw_delete_define(const char* string) {
+	int i;
+	for(i = 0; config.defined[i] != NULL; i++) {
+		if(strcmp(config.defined[i], string) == 0) {
+			free(config.defined[i]);
+			for(; config.defined[i] != NULL; i++) {
+				config.defined[i] = config.defined[i + 1];
+			}
+		}
+	}
+}
+
 void tw_init_tools(struct tw_tool* tools) {
 	tools->log = cm_log;
 	tools->add_version = tw_add_version;
+	tools->add_define = tw_add_define;
 }
 
Index: trunk/Server/tw_config.h
===================================================================
--- trunk/Server/tw_config.h	(revision 155)
+++ trunk/Server/tw_config.h	(revision 156)
@@ -7,4 +7,6 @@
 extern "C" {
 #endif
+
+#include "../config.h"
 
 #include "tw_http.h"
@@ -62,6 +64,8 @@
 	char* name;
 	int port;
+#ifndef NO_SSL
 	char* sslkey;
 	char* sslcert;
+#endif
 	char* root;
 	int hideport;
@@ -76,4 +80,7 @@
 	char* readmes[MAX_README];
 	int readme_count;
+#ifdef HAS_CHROOT
+	char* chroot_path;
+#endif
 };
 
@@ -81,4 +88,5 @@
 	uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
 	char hostname[1025];
+	char* defined[1025];
 	struct tw_config_entry root;
 	struct tw_config_entry vhosts[MAX_VHOSTS];
Index: trunk/Server/tw_module.h
===================================================================
--- trunk/Server/tw_module.h	(revision 155)
+++ trunk/Server/tw_module.h	(revision 156)
@@ -14,4 +14,6 @@
 	void (*log)(const char* name, const char* log, ...);
 	void (*add_version)(const char* string);
+	void (*add_define)(const char* string);
+	void (*delete_define)(const char* string);
 };
 
@@ -45,4 +47,8 @@
 void tw_init_tools(struct tw_tool* tools);
 int tw_module_init(void* mod);
+
+void tw_add_version(const char* string);
+void tw_add_define(const char* string);
+void tw_delete_define(const char* string);
 #endif
 
Index: trunk/Server/tw_version.h
===================================================================
--- trunk/Server/tw_version.h	(revision 155)
+++ trunk/Server/tw_version.h	(revision 156)
@@ -8,5 +8,5 @@
 #endif
 
-#define TW_VERSION "1.06C\0"
+#define TW_VERSION "1.07\0"
 
 const char* tw_get_version(void);
Index: trunk/config.h.tmpl
===================================================================
--- trunk/config.h.tmpl	(revision 155)
+++ trunk/config.h.tmpl	(revision 156)
@@ -8,4 +8,5 @@
 #undef NO_SSL
 #define USE_POLL
+#define HAS_CHROOT
 
 /* DO NOT EDIT BELOW THIS LINE */
@@ -20,4 +21,9 @@
 #endif
 
+#if defined(__MINGW32__) && defined(HAS_CHROOT)
+#undef HAS_CHROOT
+/* Windows should not have chroot */
+#endif
+
 #endif
 
Index: trunk/example.conf
===================================================================
--- trunk/example.conf	(revision 155)
+++ trunk/example.conf	(revision 156)
@@ -5,5 +5,5 @@
 
 #LoadModule Module/mod_cgi.so
-LoadModule Module/mod_proxy.so
+#LoadModule Module/mod_proxy.so
 
 Listen 80
@@ -30,3 +30,11 @@
 DocumentRoot /var/www
 
-#ProxyPass
+Define test
+Undefine test
+
+BeginIf Defined test
+	ForceLog "defined"
+EndIf
+BeginIfNot Defined test
+	ForceLog "not defined"
+EndIf
