Index: 2.03E/Server/gui.c
===================================================================
--- trunk/Server/gui.c	(revision 253)
+++ 2.03E/Server/gui.c	(revision 254)
@@ -19,4 +19,6 @@
 HWND button_stop;
 HWND button_about;
+HWND button_reset;
+HWND button_exit;
 HWND status;
 HFONT monospace;
@@ -33,5 +35,5 @@
 int startup(int argc, char** argv);
 
-void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h){
+void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h) {
 	HBITMAP hBitmap = LoadBitmap(hInst, name);
 	BITMAP bmp;
@@ -40,7 +42,7 @@
 	hmdc = CreateCompatibleDC(hdc);
 	SelectObject(hmdc, hBitmap);
-	if(w == 0 && h == 0){
+	if(w == 0 && h == 0) {
 		StretchBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
-	}else{
+	} else {
 		StretchBlt(hdc, x, y, w, h, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
 	}
@@ -49,10 +51,8 @@
 }
 
-void ShowBitmap(HWND hWnd, HDC hdc, const char* name, int x, int y){
-	ShowBitmapSize(hWnd, hdc, name, x, y, 0, 0);
-}
+void ShowBitmap(HWND hWnd, HDC hdc, const char* name, int x, int y) { ShowBitmapSize(hWnd, hdc, name, x, y, 0, 0); }
 
 int max = 0;
-void AddLog(const char* str){
+void AddLog(const char* str) {
 	HDC hdc;
 	PAINTSTRUCT ps;
@@ -65,6 +65,6 @@
 	GetTextExtentPoint32(hdc, str, strlen(str), &sz);
 	DeleteDC(hdc);
-	
-	if(max < sz.cx){
+
+	if(max < sz.cx) {
 		max = sz.cx;
 		SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
@@ -72,8 +72,8 @@
 }
 
-LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
-	if(msg == WM_COMMAND){
+LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
+	if(msg == WM_COMMAND) {
 		if(LOWORD(wp) == IDOK) EndDialog(hWnd, IDOK);
-	}else if(msg == WM_PAINT){
+	} else if(msg == WM_PAINT) {
 		HDC hdc;
 		PAINTSTRUCT ps;
@@ -87,9 +87,9 @@
 		ShowBitmapSize(hWnd, hdc, "TEWILOGO", size.left, size.top, WINWIDTH(size), WINWIDTH(size));
 		EndPaint(hWnd, &ps);
-	}else if(msg == WM_CTLCOLORDLG || msg == WM_CTLCOLORSTATIC){
+	} else if(msg == WM_CTLCOLORDLG || msg == WM_CTLCOLORSTATIC) {
 		HDC dc = (HDC)wp;
 		SetBkMode(dc, TRANSPARENT);
 		return (LRESULT)GetSysColorBrush(COLOR_MENU);
-	}else{
+	} else {
 		return FALSE;
 	}
@@ -97,11 +97,11 @@
 }
 
-void tewi_thread(void* ptr){
+void tewi_thread(void* ptr) {
 	int st = startup(0, NULL);
 	was_starting = TRUE;
-	if(st == -1){
+	if(st == -1) {
 		tewi_alive = TRUE;
 		idle = FALSE;
-	}else{
+	} else {
 		cm_force_log("Config error");
 		idle = FALSE;
@@ -116,5 +116,5 @@
 }
 
-void StartTewi(void){
+void StartTewi(void) {
 	EnableWindow(button_start, FALSE);
 	EnableWindow(button_stop, FALSE);
@@ -122,5 +122,5 @@
 }
 
-void StopTewi(void){
+void StopTewi(void) {
 	EnableWindow(button_start, FALSE);
 	EnableWindow(button_stop, FALSE);
@@ -128,40 +128,46 @@
 }
 
-LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
-	if(msg == WM_COMMAND){
+LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
+	if(msg == WM_COMMAND) {
 		int trig = LOWORD(wp);
 		int ev = HIWORD(wp);
-		if(trig == GUI_BUTTON_ABOUT){
-			if(ev == BN_CLICKED){
+		if(trig == GUI_BUTTON_ABOUT) {
+			if(ev == BN_CLICKED) {
 				DialogBox(hInst, "VERSIONDLG", hWnd, (DLGPROC)VersionDialog);
 			}
-		}else if(trig == GUI_BUTTON_START){
-			if(ev == BN_CLICKED){
-				SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Starting Tewi HTTPd");
+		} else if(trig == GUI_BUTTON_START) {
+			if(ev == BN_CLICKED) {
+				SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Starting Tewi HTTPd");
 				StartTewi();
 			}
-		}else if(trig == GUI_BUTTON_STOP){
-			if(ev == BN_CLICKED){
-				SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopping Tewi HTTPd");
+		} else if(trig == GUI_BUTTON_STOP) {
+			if(ev == BN_CLICKED) {
+				SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
 				StopTewi();
 			}
-		}else if(trig == GUI_BUTTON_EXIT){
-			if(ev == BN_CLICKED){
-				if(tewi_alive){
-					SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopping Tewi HTTPd");
+		} else if(trig == GUI_BUTTON_RESET) {
+			if(ev == BN_CLICKED) {
+				SendMessage(logarea, LB_RESETCONTENT, 0, 0);
+				max = 0;
+				SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
+			}
+		} else if(trig == GUI_BUTTON_EXIT) {
+			if(ev == BN_CLICKED) {
+				if(tewi_alive) {
+					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
 					StopTewi();
 					exiting = TRUE;
-				}else{
+				} else {
 					SendMessage(hWnd, WM_CLOSE, 0, 0);
 				}
 			}
-		}else if(trig == GUI_LOG){
+		} else if(trig == GUI_LOG) {
 		}
-	}else if(msg == WM_CLOSE){
+	} else if(msg == WM_CLOSE) {
 		DestroyWindow(hWnd);
-	}else if(msg == WM_DESTROY){
+	} else if(msg == WM_DESTROY) {
 		DeleteObject(pbtewi_brush);
 		PostQuitMessage(0);
-	}else if(msg == WM_CREATE){
+	} else if(msg == WM_CREATE) {
 		RECT rc, src;
 		GetClientRect(hWnd, &rc);
@@ -173,5 +179,5 @@
 		status = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, NULL, hWnd, GUI_STATUS);
 		SendMessage(status, SB_SIMPLE, 0, 0);
-		SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Welcome to Tewi HTTPd");
+		SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Welcome to Tewi HTTPd");
 		SendMessage(status, SB_GETRECT, 0, (LPARAM)&src);
 
@@ -180,5 +186,6 @@
 		button_stop = CreateWindow("BUTTON", "S&top", WS_CHILD | WS_VISIBLE | WS_DISABLED | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 1, 100, 20, hWnd, (HMENU)GUI_BUTTON_STOP, hInst, NULL);
 		button_about = CreateWindow("BUTTON", "&About", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 2, 100, 20, hWnd, (HMENU)GUI_BUTTON_ABOUT, hInst, NULL);
-		button_about = CreateWindow("BUTTON", "E&xit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_EXIT, hInst, NULL);
+		button_reset = CreateWindow("BUTTON", "&Reset", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20 - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_RESET, hInst, NULL);
+		button_exit = CreateWindow("BUTTON", "E&xit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_EXIT, hInst, NULL);
 		logarea = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT | LBS_NOSEL, 0, 40, WINWIDTH(rc) - 100, WINHEIGHT(rc) - 40 - WINHEIGHT(src), hWnd, (HMENU)GUI_LOG, hInst, NULL);
 
@@ -186,23 +193,23 @@
 
 		SetTimer(hWnd, TIMER_WATCH_TEWI, 100, NULL);
-	}else if(msg == WM_TIMER){
-		if(wp == TIMER_WATCH_TEWI){
-			if(idle){
-			}else if(tewi_alive){
-				if(was_starting){
+	} else if(msg == WM_TIMER) {
+		if(wp == TIMER_WATCH_TEWI) {
+			if(idle) {
+			} else if(tewi_alive) {
+				if(was_starting) {
 					was_starting = FALSE;
-					SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Started Tewi HTTPd");
+					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Started Tewi HTTPd");
 				}
 				EnableWindow(button_start, FALSE);
 				EnableWindow(button_stop, TRUE);
 				idle = TRUE;
-			}else{
-				if(was_starting){
+			} else {
+				if(was_starting) {
 					was_starting = FALSE;
-					SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopped Tewi HTTPd");
+					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopped Tewi HTTPd");
 				}
 				EnableWindow(button_start, TRUE);
 				EnableWindow(button_stop, FALSE);
-				if(exiting){
+				if(exiting) {
 					KillTimer(hWnd, TIMER_WATCH_TEWI);
 					SendMessage(hWnd, WM_CLOSE, 0, 0);
@@ -211,5 +218,5 @@
 			}
 		}
-	}else if(msg == WM_PAINT){
+	} else if(msg == WM_PAINT) {
 		HDC hdc;
 		PAINTSTRUCT ps;
@@ -223,5 +230,5 @@
 		ShowBitmap(hWnd, hdc, "PBTEWI", 0, 0);
 		EndPaint(hWnd, &ps);
-	}else{
+	} else {
 		return DefWindowProc(hWnd, msg, wp, lp);
 	}
@@ -229,5 +236,5 @@
 }
 
-BOOL InitApp(void){
+BOOL InitApp(void) {
 	WNDCLASSEX wc;
 	wc.cbSize = sizeof(WNDCLASSEX);
@@ -246,5 +253,5 @@
 }
 
-BOOL InitWindow(int nCmdShow){
+BOOL InitWindow(int nCmdShow) {
 	HWND hWnd;
 	RECT deskrc, rc;
@@ -253,5 +260,5 @@
 	hWnd = CreateWindow("tewihttpd", "Tewi HTTPd", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) ^ WS_MAXIMIZEBOX, 0, 0, 600, 400, NULL, 0, hInst, NULL);
 
-	if(!hWnd){
+	if(!hWnd) {
 		return FALSE;
 	}
@@ -263,5 +270,5 @@
 }
 
-int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow){
+int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow) {
 	MSG msg;
 	BOOL bret;
@@ -272,12 +279,12 @@
 	idle = TRUE;
 	logfile = stderr;
-	if(!InitApp()){
-		return FALSE;
-	}
-	if(!InitWindow(nCmdShow)){
-		return FALSE;
-	}
-
-	while((bret = GetMessage(&msg, NULL, 0, 0)) != 0){
+	if(!InitApp()) {
+		return FALSE;
+	}
+	if(!InitWindow(nCmdShow)) {
+		return FALSE;
+	}
+
+	while((bret = GetMessage(&msg, NULL, 0, 0)) != 0) {
 		if(bret == -1) {
 			break;
