Index: /trunk/Common/Makefile
===================================================================
--- /trunk/Common/Makefile	(revision 2)
+++ /trunk/Common/Makefile	(revision 3)
@@ -6,5 +6,5 @@
 .SUFFIXES: .c .o
 
-OBJS = string.o
+OBJS = string.o log.o
 
 all: common.a
Index: /trunk/Common/cm_log.h
===================================================================
--- /trunk/Common/cm_log.h	(revision 3)
+++ /trunk/Common/cm_log.h	(revision 3)
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef __CM_LOG_H__
+#define __CM_LOG_H__
+
+void cm_log(const char* name, const char* log, ...);
+
+#endif
Index: /trunk/Common/cm_string.h
===================================================================
--- /trunk/Common/cm_string.h	(revision 3)
+++ /trunk/Common/cm_string.h	(revision 3)
@@ -0,0 +1,9 @@
+/* $Id$ */
+
+#ifndef __CM_STRING_H__
+#define __CM_STRING_H__
+
+char* cm_strcat(const char* a, const char* b);
+char* cm_strdup(const char* str);
+
+#endif
Index: /trunk/Common/log.c
===================================================================
--- /trunk/Common/log.c	(revision 3)
+++ /trunk/Common/log.c	(revision 3)
@@ -0,0 +1,55 @@
+/* $Id$ */
+
+#include "cm_log.h"
+
+#include "cm_string.h"
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+bool cm_do_log = false;
+
+#define LOGNAME_LENGTH 12
+
+void cm_log(const char* name, const char* log, ...) {
+	if(!cm_do_log) return;
+	va_list args;
+	va_start(args, log);
+	char namebuf[LOGNAME_LENGTH + 1];
+	memset(namebuf, '.', LOGNAME_LENGTH);
+	namebuf[LOGNAME_LENGTH] = 0;
+	int i;
+	for(i = 0; name[i] != 0 && i < LOGNAME_LENGTH; i++) {
+		namebuf[i] = name[i];
+	}
+
+	char* result = malloc(1);
+	result[0] = 0;
+
+	char cbuf[2];
+	cbuf[1] = 0;
+
+	for(i = 0; log[i] != 0; i++) {
+		if(log[i] == '%') {
+			i++;
+			if(log[i] == 's') {
+				char* tmp = result;
+				result = cm_strcat(tmp, va_arg(args, char*));
+				free(tmp);
+			}
+		} else {
+			cbuf[0] = log[i];
+			char* tmp = result;
+			result = cm_strcat(tmp, cbuf);
+			free(tmp);
+		}
+	}
+
+	fprintf(stderr, "%s %s\n", namebuf, result);
+	va_end(args);
+
+	free(result);
+}
Index: /trunk/Common/string.c
===================================================================
--- /trunk/Common/string.c	(revision 2)
+++ /trunk/Common/string.c	(revision 3)
@@ -1,1 +1,14 @@
 /* $Id$ */
+
+#include <string.h>
+#include <stdlib.h>
+
+char* cm_strcat(const char* a, const char* b) {
+	char* str = malloc(strlen(a) + strlen(b) + 1);
+	memcpy(str, a, strlen(a));
+	memcpy(str + strlen(a), b, strlen(b));
+	str[strlen(a) + strlen(b)] = 0;
+	return str;
+}
+
+char* cm_strdup(const char* str) { return cm_strcat(str, ""); }
Index: /trunk/Platform/generic.mk
===================================================================
--- /trunk/Platform/generic.mk	(revision 2)
+++ /trunk/Platform/generic.mk	(revision 3)
@@ -3,5 +3,5 @@
 CC = cc
 AR = ar
-CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\"
+CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common
 LDFLAGS =
 LIBS =
Index: /trunk/Server/Makefile
===================================================================
--- /trunk/Server/Makefile	(revision 2)
+++ /trunk/Server/Makefile	(revision 3)
@@ -6,10 +6,10 @@
 .SUFFIXES: .c .o
 
-OBJS = ../Common/common.a main.o
+OBJS = version.o main.o
 
 all: tewi$(EXEC)
 
-tewi$(EXEC): $(OBJS)
-	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+tewi$(EXEC): $(OBJS) ../Common/common.a
+	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ../Common/common.a
 
 .c.o:
Index: /trunk/Server/main.c
===================================================================
--- /trunk/Server/main.c	(revision 2)
+++ /trunk/Server/main.c	(revision 3)
@@ -1,3 +1,31 @@
 /* $Id$ */
 
-int main() {}
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <cm_log.h>
+
+#include "tw_version.h"
+
+extern bool cm_do_log;
+
+int main(int argc, char** argv) {
+	int i;
+	for(i = 1; i < argc; i++) {
+		if(argv[i][0] == '-') {
+			if(strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) {
+				if(!cm_do_log) {
+					cm_do_log = true;
+					cm_log("", "This is Tewi HTTPd, version %s", tw_get_version());
+				} else {
+					cm_do_log = true;
+				}
+			} else {
+				fprintf(stderr, "Unknown option: %s\n", argv[i]);
+				return 1;
+			}
+		}
+	}
+	cm_log("Daemon", "Ready");
+}
Index: /trunk/Server/tw_version.h
===================================================================
--- /trunk/Server/tw_version.h	(revision 3)
+++ /trunk/Server/tw_version.h	(revision 3)
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef __TW_VERSION_H__
+#define __TW_VERSION_H__
+
+const char* tw_get_version(void);
+
+#endif
Index: /trunk/Server/version.c
===================================================================
--- /trunk/Server/version.c	(revision 3)
+++ /trunk/Server/version.c	(revision 3)
@@ -0,0 +1,7 @@
+/* $Id$ */
+
+#include "tw_version.h"
+
+const char* tw_version = "0.00";
+
+const char* tw_get_version(void) { return tw_version; }
