Index: /uKadecot/trunk/src/ukadecot/arduino.c
===================================================================
--- /uKadecot/trunk/src/ukadecot/arduino.c	(revision 154)
+++ /uKadecot/trunk/src/ukadecot/arduino.c	(revision 155)
@@ -58,13 +58,13 @@
 	 * モジュールストップ機能の設定(S12AD)
 	 */
-	sil_wrh_mem((uint16_t *)SYSTEM_PRCR_ADDR, (uint16_t)0xA502);	/* 書込み許可 */
-	sil_wrw_mem((uint32_t *)SYSTEM_MSTPCRA_ADDR,
-		sil_rew_mem((uint32_t *)SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA17_BIT);
-	sil_wrh_mem((uint16_t *)SYSTEM_PRCR_ADDR, (uint16_t)0xA500);	/* 書込み禁止 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA502);	/* 書込み許可 */
+	sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
+		sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA17_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA500);	/* 書込み禁止 */
 
 	/* 12bitADC初期化 */
-	sil_wrh_mem((uint16_t *)S12AD_ADEXICR_ADDR, 0x0000);	/* 温度センサ出力、内部基準電圧非選択 */
-	sil_wrh_mem((uint16_t *)S12AD_ADANS0_ADDR, 0x00FF);		/* 変換ポートAN000〜AN007選択、AN008〜AN015非選択 */
-	sil_wrh_mem((uint16_t *)S12AD_ADANS1_ADDR, 0x0000);		/* 変換ポートAN016〜AN020非選択 */
+	sil_wrh_mem(S12AD_ADEXICR_ADDR, 0x0000);	/* 温度センサ出力、内部基準電圧非選択 */
+	sil_wrh_mem(S12AD_ADANS0_ADDR, 0x00FF);		/* 変換ポートAN000〜AN007選択、AN008〜AN015非選択 */
+	sil_wrh_mem(S12AD_ADANS1_ADDR, 0x0000);		/* 変換ポートAN016〜AN020非選択 */
 
 	/* PWM出力(490Hz) */
@@ -157,7 +157,7 @@
 
 	/* 書き込みプロテクトレジスタの設定 PFSWEビットへの書き込みを許可 */
-	sil_wrb_mem((uint8_t *)MPC_PWPR_ADDR, 0x00);
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x00);
 	/* 書き込みプロテクトレジスタの設定 PxxFSレジスタへの書き込みを許可 */
-	sil_wrb_mem((uint8_t *)MPC_PWPR_ADDR, 0x40);
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x40);
 
 	switch(pin){
@@ -166,9 +166,9 @@
 		if(gpio){
 			/* P21端子機能制御レジスタ P21とする */
-			sil_wrb_mem((uint8_t *)MPC_P21PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P21PFS_ADDR, 0x00);
 		}
 		else{
 			/* P21端子機能制御レジスタ TIOCA3とする */
-			sil_wrb_mem((uint8_t *)MPC_P21PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P21PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -178,9 +178,9 @@
 		if(gpio){
 			/* P20端子機能制御レジスタ P20とする */
-			sil_wrb_mem((uint8_t *)MPC_P20PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P20PFS_ADDR, 0x00);
 		}
 		else{
 			/* P20端子機能制御レジスタ TIOCB3とする */
-			sil_wrb_mem((uint8_t *)MPC_P20PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P20PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -190,9 +190,9 @@
 		if(gpio){
 			/* P22端子機能制御レジスタ P22とする */
-			sil_wrb_mem((uint8_t *)MPC_P22PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P22PFS_ADDR, 0x00);
 		}
 		else{
 			/* P22端子機能制御レジスタ TIOCC3とする */
-			sil_wrb_mem((uint8_t *)MPC_P22PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P22PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -202,9 +202,9 @@
 		if(gpio){
 			/* P23端子機能制御レジスタ P23とする */
-			sil_wrb_mem((uint8_t *)MPC_P23PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P23PFS_ADDR, 0x00);
 		}
 		else{
 			/* P23端子機能制御レジスタ TIOCD3とする */
-			sil_wrb_mem((uint8_t *)MPC_P23PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P23PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -214,9 +214,9 @@
 		if(gpio){
 			/* P24端子機能制御レジスタ P24とする */
-			sil_wrb_mem((uint8_t *)MPC_P24PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P24PFS_ADDR, 0x00);
 		}
 		else{
 			/* P24端子機能制御レジスタ TIOCB4とする */
-			sil_wrb_mem((uint8_t *)MPC_P24PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P24PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -226,9 +226,9 @@
 		if(gpio){
 			/* P25端子機能制御レジスタ P25とする */
-			sil_wrb_mem((uint8_t *)MPC_P25PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P25PFS_ADDR, 0x00);
 		}
 		else{
 			/* P25端子機能制御レジスタ TIOCA4とする */
-			sil_wrb_mem((uint8_t *)MPC_P25PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P25PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -238,9 +238,9 @@
 		if(gpio){
 			/* P32端子機能制御レジスタ P32とする */
-			sil_wrb_mem((uint8_t *)MPC_P32PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P32PFS_ADDR, 0x00);
 		}
 		else{
 			/* P32端子機能制御レジスタ TIOCC0とする */
-			sil_wrb_mem((uint8_t *)MPC_P32PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P32PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -250,9 +250,9 @@
 		if(gpio){
 			/* P33端子機能制御レジスタ P33とする */
-			sil_wrb_mem((uint8_t *)MPC_P33PFS_ADDR, 0x00);
+			sil_wrb_mem(MPC_P33PFS_ADDR, 0x00);
 		}
 		else{
 			/* P33端子機能制御レジスタ TIOCD0とする */
-			sil_wrb_mem((uint8_t *)MPC_P33PFS_ADDR, 0x03);
+			sil_wrb_mem(MPC_P33PFS_ADDR, 0x03);
 		}
 		result =  E_OK;
@@ -261,5 +261,5 @@
 
 	/* 書き込みプロテクトレジスタの設定 書き込みを禁止 */
-	sil_wrb_mem((uint8_t *)MPC_PWPR_ADDR, 0x80);
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x80);
 
 	/* 機能ポートに設定 */
@@ -314,7 +314,7 @@
 }
 
-static ER change_pin_mode(arduino_pin_mode_t mode, volatile uint8_t *pdr, int bit)
-{
-	volatile uint8_t *pcr = pdr + (PORT0_PCR_ADDR - PORT0_PDR_ADDR);
+static ER change_pin_mode(arduino_pin_mode_t mode, volatile __evenaccess uint8_t *pdr, int bit)
+{
+	volatile __evenaccess uint8_t *pcr = pdr + (PORT0_PCR_ADDR - PORT0_PDR_ADDR);
 
 	switch(mode){
@@ -388,5 +388,5 @@
 }
 
-static ER write_gpio(arduino_digital_value_t value, volatile uint8_t *podr, int bit)
+static ER write_gpio(arduino_digital_value_t value, volatile __evenaccess uint8_t *podr, int bit)
 {
 	switch(value){
@@ -452,5 +452,5 @@
 }
 
-static ER read_gpio(volatile uint8_t *pidr, int bit, arduino_digital_value_t *result)
+static ER read_gpio(volatile __evenaccess uint8_t *pidr, int bit, arduino_digital_value_t *result)
 {
 	if ((sil_reb_mem(pidr) & bit) != 0) {
@@ -523,33 +523,33 @@
 	switch(pin){
 	case 14:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR0_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR0_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[0] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 15:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR1_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR1_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[1] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 16:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR2_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR2_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[2] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 17:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR3_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR3_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[3] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 18:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR4_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR4_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[4] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 19:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR5_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR5_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[5] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 20:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR6_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR6_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[6] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
 	case 21:
-		/* *value = sil_reh_mem((uint16_t *)S12AD_ADDR7_ADDR); */
+		/* *value = sil_reh_mem(S12AD_ADDR7_ADDR); */
 		*value = 1023 - (arduino_ad_avelage[7] / (arduino_ad_table_count * 4/*12bit→10bit*/));
 		return E_OK;
@@ -605,5 +605,5 @@
 void arduino_tick()
 {
-	static volatile uint16_t *const regs[8] = {
+	static volatile __evenaccess uint16_t *const regs[8] = {
 		S12AD_ADDR0_ADDR,
 		S12AD_ADDR1_ADDR,
@@ -619,5 +619,5 @@
 
 	/* ADCの変換結果取得 */
-	if((sil_reb_mem((uint8_t *)S12AD_ADCSR_ADDR) & S12AD_ADCSR_ADST_BIT) == 0){
+	if((sil_reb_mem(S12AD_ADCSR_ADDR) & S12AD_ADCSR_ADST_BIT) == 0){
 		for (i = 0; i < 8; i++){
 			arduino_ad_avelage[i] -= arduino_ad_table[i][arduino_ad_pos];
@@ -633,5 +633,5 @@
 
 		/* 変換開始（シングルスキャンモード） */
-		sil_wrb_mem((uint8_t *)S12AD_ADCSR_ADDR, S12AD_ADCSR_ADST_BIT);
-	}
-}
+		sil_wrb_mem(S12AD_ADCSR_ADDR, S12AD_ADCSR_ADST_BIT);
+	}
+}
Index: /uKadecot/trunk/uip/apps/webserver/http-strings
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/http-strings	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/http-strings	(revision 155)
@@ -8,5 +8,5 @@
 http_content_type "content-type: "
 http_texthtml "text/html"
-http_location "location: "
+http_location "Location: "
 http_host "host: "
 http_crnl "\r\n"
@@ -21,4 +21,5 @@
 http_header_101 "HTTP/1.1 101 Switching Protocols\r\n"
 http_header_200 "HTTP/1.1 200 OK\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n"
+http_header_301 "HTTP/1.1 301 Moved Permanently\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n"
 http_header_404 "HTTP/1.1 404 Not found\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n"
 http_content_encoding_gzip "Content-Encoding: gzip\r\n"
Index: /uKadecot/trunk/uip/apps/webserver/http-strings.c
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/http-strings.c	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/http-strings.c	(revision 155)
@@ -27,6 +27,6 @@
 {0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
 const char http_location[11] = 
-/* "location: " */
-{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
+/* "Location: " */
+{0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
 const char http_host[7] = 
 /* "host: " */
@@ -65,4 +65,7 @@
 /* "HTTP/1.1 200 OK\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n" */
 {0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x74, 0x6f, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x6a, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
+const char http_header_301[92] = 
+/* "HTTP/1.1 301 Moved Permanently\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f, 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d, 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x74, 0x6f, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x6a, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
 const char http_header_404[84] = 
 /* "HTTP/1.1 404 Not found\r\nServer: uIP/1.0 http://www.toppers.jp/\r\nConnection: close\r\n" */
Index: /uKadecot/trunk/uip/apps/webserver/http-strings.h
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/http-strings.h	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/http-strings.h	(revision 155)
@@ -21,4 +21,5 @@
 extern const char http_header_101[35];
 extern const char http_header_200[77];
+extern const char http_header_301[92];
 extern const char http_header_404[84];
 extern const char http_content_encoding_gzip[25];
Index: /uKadecot/trunk/uip/apps/webserver/httpd-fs.c
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/httpd-fs.c	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/httpd-fs.c	(revision 155)
@@ -40,4 +40,11 @@
 #include "mmc_rspi.h"
 #include <string.h>
+#include "http-strings.h"
+
+#ifndef _MSC_VER
+#ifndef strcat_s
+#define strcat_s(dst, dsz, src) strcat(dst, src)
+#endif
+#endif
 
 //#define FILE_DUMP
@@ -114,8 +121,10 @@
 /*-----------------------------------------------------------------------------------*/
 int
-httpd_fs_open(int drv, const char *name, struct httpd_fs_file *file)
+httpd_fs_open(int drv, char *name, int len, struct httpd_fs_file *file)
 {
 	FRESULT res;
-	FATFS *fs = (FATFS *)file->fs;
+	FATFS *fs = (FATFS *)&file->fs;
+	FILINFO fno;
+	DIR dir;
 
 	file->pos = 0;
@@ -123,4 +132,5 @@
 	file->drv = drv;
 	file->name = name;
+	file->redirect = 0;
 	memset(fs, 0, sizeof(FATFS));
 
@@ -143,7 +153,28 @@
 	}
 
-	if((res = pf_open(fs, name)) != FR_OK){
-		printf("pf_open(%d:%s) => %d\n", drv, name, res);
-		return 0;
+	if ((res = pf_open(fs, name)) != FR_OK) {
+		dir.fs = fs;
+		if ((res = pf_opendir(&dir, name)) != FR_OK) {
+			printf("pf_opendir(%d:%s) => %d\n", drv, name, res);
+			return 0;
+		}
+
+		if ((res = pf_readdir(&dir, &fno)) != FR_OK) {
+			printf("pf_readdir(%d:%s) => %d\n", drv, name, res);
+			return 0;
+		}
+
+		if (len != 0/*fno.fattrib & AM_DIR*/) {
+			strcat_s(name, len, http_index_html);
+			res = pf_open(fs, name);
+			file->redirect = res == FR_OK;
+		}
+		else
+			res = FR_NO_FILE;
+
+		if (res != FR_OK) {
+			printf("pf_open(%d:%s) => %d %x\n", drv, name, res, fno.fattrib);
+			return 0;
+		}
 	}
 
@@ -160,5 +191,5 @@
 	FRESULT ret;
 	UINT rlen;
-	FATFS *fs = (FATFS *)file->fs;
+	FATFS *fs = (FATFS *)&file->fs;
 
 	if((ret = pf_lseek(fs, file->pos)) != FR_OK){
Index: /uKadecot/trunk/uip/apps/webserver/httpd-fs.h
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/httpd-fs.h	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/httpd-fs.h	(revision 155)
@@ -43,10 +43,11 @@
   int drv;
   const char *name;
-  void *fs;
+  int redirect;
+  char fs[64 + 512/*sizeof(FATFS)*/];
 };
 
 /* file must be allocated by caller and will be filled in
    by the function. */
-int httpd_fs_open(int drv, const char *name, struct httpd_fs_file *file);
+int httpd_fs_open(int drv, char *name, int len, struct httpd_fs_file *file);
 int httpd_fs_read(struct httpd_fs_file *file, void *dst, int len);
 
Index: /uKadecot/trunk/uip/apps/webserver/httpd.c
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/httpd.c	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/httpd.c	(revision 155)
@@ -203,4 +203,17 @@
   }
 
+  if (s->file.redirect) {
+    len = strlen(http_location);
+    memcpy(pos, http_location, len); pos += len;
+    if (s->drv == 1) {
+      len = 2;
+      memcpy(pos, "/~", len); pos += len;
+    }
+    len = strlen(s->filename);
+    memcpy(pos, s->filename, len); pos += len;
+    len = 2;
+    memcpy(pos, "\r\n", len); pos += len;
+  }
+
   ptr = strrchr(s->message.request_url, ISO_period);
   if (ptr == NULL) {
@@ -248,10 +261,8 @@
   PT_BEGIN(&s->outputpt);
 
-  s->file.fs = ((char *)&s[1]) - 64 - 512;
-
-  if (!httpd_fs_open(s->drv, s->filename, &s->file)) {
+  if (!httpd_fs_open(s->drv, s->filename, sizeof(s->filename), &s->file)) {
     s->drv = 0;
-    httpd_fs_open(s->drv, http_404_html, &s->file);
-    strcpy_s(s->message.request_url, sizeof(s->message.request_url), http_404_html);
+    strcpy_s(s->filename, sizeof(s->filename), http_404_html);
+    httpd_fs_open(s->drv, s->filename, sizeof(s->filename), &s->file);
     PT_WAIT_THREAD(&s->outputpt,
       send_headers(s,
@@ -261,5 +272,5 @@
     PT_WAIT_THREAD(&s->outputpt,
       send_headers(s,
-      http_header_200));
+      s->file.redirect ? http_header_301 : http_header_200));
     PT_WAIT_THREAD(&s->outputpt, send_file(s));
   }
@@ -381,4 +392,6 @@
   size_t done;
   const char *data;
+  char *ptr;
+
   PSOCK_BEGIN(&s->sin);
 
@@ -407,16 +420,20 @@
   /* ""か"/"なら"index.html"に変更 */
   if ((s->message.request_url[0] == '\0') || ((s->message.request_url[0] == '/') && (s->message.request_url[1] == '\0'))) {
-    strncpy_s(s->message.request_url, sizeof(s->message.request_url), http_index_html, sizeof(s->message.request_url));
-    s->filename = s->message.request_url;
+    s->drv = 0;
+    strcpy_s(s->filename, sizeof(s->filename), http_index_html);
   }
   /* "/~/"ならSDカードから読み込み */
   else if ((s->message.request_url[0] == '/') && (s->message.request_url[1] == '~') && (s->message.request_url[2] == '/')) {
     s->drv = 1;
-    s->filename = &s->message.request_url[2];
+    strcpy_s(s->filename, sizeof(s->filename), &s->message.request_url[2]);
   }
   else {
     s->drv = 0;
-    s->filename = s->message.request_url;
-  }
+    strcpy_s(s->filename, sizeof(s->filename), s->message.request_url);
+  }
+
+  ptr = strrchr(s->filename, '?');
+  if (ptr != NULL)
+    ptr[0] = '\0';
 
   /*  httpd_log_file(uip_conn->ripaddr, s->message.request_url);*/
@@ -426,4 +443,5 @@
     s->state = STATE_WS_OUTPUT;
 
+    s->close_req = 0;
     websocket_init(&s->websocket, uip_getid((struct uip_conn *)((intptr_t)s - offsetof(struct uip_conn, appstate))));
     for (;;) {
Index: /uKadecot/trunk/uip/apps/webserver/httpd.h
===================================================================
--- /uKadecot/trunk/uip/apps/webserver/httpd.h	(revision 154)
+++ /uKadecot/trunk/uip/apps/webserver/httpd.h	(revision 155)
@@ -47,15 +47,25 @@
   char inputbuf[50];
   char state;
-  int drv;
-  char *filename;
-  int len;
-  struct httpd_fs_file file;
-  int parse_pos;
-  int parse_len;
-  struct http_parser parser;
-  struct http_parser_url handle;
-  struct message message;
-  struct websocket websocket;
-  int close_req;
+  union{
+    struct{
+      int parse_pos;
+      int parse_len;
+      struct http_parser parser;
+      struct http_parser_url handle;
+      struct message message;
+    };
+    struct{
+      char _dummy1[340];
+      int drv;
+      char filename[256];
+      int len;
+      struct httpd_fs_file file;
+    };
+    struct{
+      char _dummy2[340];
+      struct websocket websocket;
+      int close_req;
+    };
+  };
 };
 #define get_context(p) (struct httpd_state *)((intptr_t)p - (intptr_t)&((struct httpd_state *)0)->parser)
