Index: EcnlProtoTool/trunk/ntshell/webserver/httpd.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/webserver/httpd.c	(revision 441)
+++ EcnlProtoTool/trunk/ntshell/webserver/httpd.c	(revision 442)
@@ -53,5 +53,4 @@
 #include "base64.h"
 #include "sha1.h"
-#include "util/ntstdio.h"
 #include "core/ntlibc.h"
 
@@ -59,5 +58,4 @@
 #define FALSE 0
 
-extern ntstdio_t *ntstdio;
 SYSTIM httpd_time;
 struct httpd_state *uploding;
@@ -111,5 +109,5 @@
 void strcpy_s(char *dst, int size, const char *src)
 {
-	int slen = ntlibc_strlen(src);
+	int slen = strlen(src);
 	if (slen >= size)
 		slen = size - 1;
@@ -120,6 +118,6 @@
 void strcat_s(char *dst, int size, const char *src)
 {
-	int dlen = ntlibc_strlen(dst);
-	int slen = ntlibc_strlen(src);
+	int dlen = strlen(dst);
+	int slen = strlen(src);
 	if (dlen + slen >= size)
 		slen = size - 1 - dlen;
@@ -235,26 +233,26 @@
 	struct message *m = &s->message;
 
-	if (ntlibc_strncmp("Referer", buf, len) == 0) {
+	if (strncmp("Referer", buf, len) == 0) {
 		m->num_headers = 1;
 	}
-	else if (ntlibc_strncmp("Host", buf, len) == 0) {
+	else if (strncmp("Host", buf, len) == 0) {
 		m->num_headers = 2;
 	}
-	else if (ntlibc_strncmp("Upgrade", buf, len) == 0) {
+	else if (strncmp("Upgrade", buf, len) == 0) {
 		m->num_headers = 3;
 	}
-	else if (ntlibc_strncmp("Connection", buf, len) == 0) {
+	else if (strncmp("Connection", buf, len) == 0) {
 		m->num_headers = 4;
 	}
-	else if (ntlibc_strncmp("Sec-WebSocket-Key", buf, len) == 0) {
+	else if (strncmp("Sec-WebSocket-Key", buf, len) == 0) {
 		m->num_headers = 5;
 	}
-	else if (ntlibc_strncmp("Origin", buf, len) == 0) {
+	else if (strncmp("Origin", buf, len) == 0) {
 		m->num_headers = 6;
 	}
-	else if (ntlibc_strncmp("Sec-WebSocket-Protocol", buf, len) == 0) {
+	else if (strncmp("Sec-WebSocket-Protocol", buf, len) == 0) {
 		m->num_headers = 7;
 	}
-	else if (ntlibc_strncmp("Sec-WebSocket-Version", buf, len) == 0) {
+	else if (strncmp("Sec-WebSocket-Version", buf, len) == 0) {
 		m->num_headers = 8;
 	}
@@ -334,5 +332,5 @@
 			// アップロード先はSDカード
 			s->filename[0] = '1';
-			ntstdio_printf(ntstdio, "create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+			printf("create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 			if (!httpd_fs_create(s->filename, &s->file)) {
 				goto error;
@@ -341,6 +339,6 @@
 			s->in.state = IN_STATE_UPLOAD;
 		}
-		else if (ntlibc_strcmp(s->filename, uploding->filename) == 0) {
-			ntstdio_printf(ntstdio, "collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+		else if (strcmp(s->filename, uploding->filename) == 0) {
+			printf("collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 			goto error;
 		}
@@ -374,5 +372,5 @@
 
 	if (s->message.body_is_final) {
-		ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
+		printf("\n\n *** Error http_body_is_final() should return 1 \n"
 			"on last on_body callback call "
 			"but it doesn't! ***\n\n");
@@ -387,5 +385,5 @@
 
 	if (s->message.body_is_final) {
-		ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+		printf("close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 		httpd_fs_close(&s->file);
 		memset(&s->file, 0, sizeof(s->file));
@@ -412,5 +410,5 @@
 	struct httpd_state *s = get_context(p);
 	if (s->message.should_keep_alive != http_should_keep_alive(p)) {
-		ntstdio_printf(ntstdio, "\n\n *** Error http_should_keep_alive() should have same \n"
+		printf("\n\n *** Error http_should_keep_alive() should have same \n"
 			"value in both on_message_complete and on_headers_complete "
 			"but it doesn't! ***\n\n");
@@ -421,5 +419,5 @@
 		http_body_is_final(p) &&
 		!s->message.body_is_final) {
-		ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
+		printf("\n\n *** Error http_body_is_final() should return 1 \n"
 			"on last on_body callback call "
 			"but it doesn't! ***\n\n");
@@ -493,5 +491,5 @@
 		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
 		if (slen < 0) {
-			ntstdio_printf(ntstdio, "send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			printf("send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
 			s->state = STATE_CLOSING;
 			break;
@@ -506,5 +504,5 @@
 		len = httpd_fs_read(&s->file, buf, len);
 		if (len <= 0) {
-			ntstdio_printf(ntstdio, "send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+			printf("send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
 			break;
 		}
@@ -514,5 +512,5 @@
 
 		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
-			ntstdio_printf(ntstdio, "send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			printf("send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
 			s->state = STATE_CLOSING;
 			break;
@@ -520,5 +518,5 @@
 	}
 
-	ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+	printf("close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 	httpd_fs_close(&s->file);
 	s->file.len = 0;
@@ -536,5 +534,5 @@
 		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
 		if (slen < 0) {
-			ntstdio_printf(ntstdio, "send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			printf("send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
 			s->state = STATE_CLOSING;
 			break;
@@ -553,5 +551,5 @@
 
 		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
-			ntstdio_printf(ntstdio, "send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			printf("send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
 			s->state = STATE_CLOSING;
 			break;
@@ -571,5 +569,5 @@
 	char *ptr;
 
-	len = ntlibc_strlen(statushdr);
+	len = strlen(statushdr);
 	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
 
@@ -586,9 +584,9 @@
 			tcp_snd_dat(s->cepid, "/~", len, TMO_FEVR);
 		}
-		len = ntlibc_strlen(s->filename);
+		len = strlen(s->filename);
 		tcp_snd_dat(s->cepid, s->filename, len, TMO_FEVR);
 		if (s->query != NULL) {
 			tcp_snd_dat(s->cepid, "?", 1, TMO_FEVR);
-			len = ntlibc_strlen(s->query);
+			len = strlen(s->query);
 			tcp_snd_dat(s->cepid, s->query, len, TMO_FEVR);
 		}
@@ -602,58 +600,58 @@
 		tcp_snd_dat(s->cepid, (void *)http_content_type_binary, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
-		ntlibc_strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
+	else if (strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
+		strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
 		len = sizeof(http_content_type_html) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_html, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
+	else if (strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
 		len = sizeof(http_content_type_css) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_css, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
+	else if (strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
 		len = sizeof(http_content_type_js) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_js, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
+	else if (strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
 		len = sizeof(http_content_type_json) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_json, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
+	else if (strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
 		len = sizeof(http_content_type_png) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_png, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
+	else if (strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
 		len = sizeof(http_content_type_gif) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_gif, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
+	else if (strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
 		len = sizeof(http_content_type_jpg) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_jpg, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
+	else if (strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
 		len = sizeof(http_content_type_svg) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_svg, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
+	else if (strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
 		len = sizeof(http_content_type_text) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_text, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
+	else if (strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
 		len = sizeof(http_content_type_eot) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_eot, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
+	else if (strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
 		len = sizeof(http_content_type_ttf) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_ttf, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
+	else if (strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
 		len = sizeof(http_content_type_woff) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_woff, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
+	else if (strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
 		len = sizeof(http_content_type_woff2) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_woff2, len, TMO_FEVR);
 	}
-	else if (ntlibc_strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
+	else if (strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
 		len = sizeof(http_content_type_ico) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_type_ico, len, TMO_FEVR);
@@ -667,5 +665,5 @@
 		len = sizeof(http_content_length) - 1;
 		tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR);
-		len = ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);
+		len = snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);
 		tcp_snd_dat(s->cepid, (void *)s->temp, len, TMO_FEVR);
 	}
@@ -699,5 +697,5 @@
 		break;
 	case OUT_STATE_OPEN_GET_FILE:
-		ntstdio_printf(ntstdio, "open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+		printf("open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 		if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) {
 			s->filename = NULL;
@@ -713,26 +711,26 @@
 		break;
 	case OUT_STATE_WAIT_POST_BODY:
-		//ntstdio_printf(ntstdio, "wait post body\n");
+		//printf("wait post body\n");
 		s->out.wait = true;
 		break;
 	case OUT_STATE_BODY_RECEIVED:
-		//ntstdio_printf(ntstdio, "body received\n");
+		//printf("body received\n");
 		s->out.statushdr = http_header_200;
 		s->out.state = OUT_STATE_SEND_HEADER;
 		break;
 	case OUT_STATE_SEND_HEADER:
-		//ntstdio_printf(ntstdio, "send header\n");
+		//printf("send header\n");
 		send_headers(s, s->out.statushdr);
 		break;
 	case OUT_STATE_SEND_FILE:
-		//ntstdio_printf(ntstdio, "send file %d\n", s->file.len);
+		//printf("send file %d\n", s->file.len);
 		send_file(s);
 		break;
 	case OUT_STATE_SEND_DATA:
-		//ntstdio_printf(ntstdio, "send data %d\n", s->response_len);
+		//printf("send data %d\n", s->response_len);
 		send_data(s);
 		break;
 	case OUT_STATE_SEND_END:
-		//ntstdio_printf(ntstdio, "send end\n");
+		//printf("send end\n");
 		s->out.wait = true;
 		if (s->message.should_keep_alive && s->reset == 0) {
@@ -750,10 +748,10 @@
 	int len;
 
-	len = ntlibc_strlen(statushdr);
+	len = strlen(statushdr);
 	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
 
 	len = sizeof(http_upgrade) - 1;
 	tcp_snd_dat(s->cepid, (void *)http_upgrade, len, TMO_FEVR);
-	len = ntlibc_strlen(s->message.upgrade);
+	len = strlen(s->message.upgrade);
 	tcp_snd_dat(s->cepid, s->message.upgrade, len, TMO_FEVR);
 	len = sizeof(http_crnl) - 1;
@@ -762,5 +760,5 @@
 	len = sizeof(http_connection) - 1;
 	tcp_snd_dat(s->cepid, (void *)http_connection, len, TMO_FEVR);
-	len = ntlibc_strlen(s->message.connection);
+	len = strlen(s->message.connection);
 	tcp_snd_dat(s->cepid, s->message.connection, len, TMO_FEVR);
 	len = sizeof(http_crnl) - 1;
@@ -769,5 +767,5 @@
 	len = sizeof(http_sec_websocket_accept) - 1;
 	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_accept, len, TMO_FEVR);
-	len = ntlibc_strlen(s->message.response_key);
+	len = strlen(s->message.response_key);
 	tcp_snd_dat(s->cepid, s->message.response_key, len, TMO_FEVR);
 	len = sizeof(http_crnl) - 1;
@@ -776,5 +774,5 @@
 	len = sizeof(http_sec_websocket_protocol) - 1;
 	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_protocol, len, TMO_FEVR);
-	len = ntlibc_strlen(s->message.sec_websocket_protocol);
+	len = strlen(s->message.sec_websocket_protocol);
 	tcp_snd_dat(s->cepid, s->message.sec_websocket_protocol, len, TMO_FEVR);
 	len = sizeof(http_crnl) - 1;
@@ -792,5 +790,5 @@
 	slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
 	if (slen < 0) {
-		ntstdio_printf(ntstdio, "send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+		printf("send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
 		return;
 	}
@@ -856,5 +854,5 @@
 				//}
 			}
-			ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+			printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
 			uploding = NULL;
 			s->state = STATE_CLOSING;
@@ -864,5 +862,5 @@
 		tcp_rel_buf(s->cepid, done);
 		if (s->parser.http_errno != HPE_OK) {
-			ntstdio_printf(ntstdio, "http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
+			printf("http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
 			uploding = NULL;
 			s->state = STATE_CLOSING;
@@ -889,5 +887,5 @@
 					break;
 				}
-				ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+				printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
 				s->state = STATE_CLOSING;
 				break;
@@ -927,7 +925,7 @@
 
 	if (s == NULL)
-		ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %d)\n", fncd, cepid);
+		printf("callback_nblk_tcp(%d, %d)\n", fncd, cepid);
 	else
-		ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
+		printf("callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
 
 	return E_PAR;
@@ -945,5 +943,5 @@
 		ret2 = get_tim(&httpd_time);
 		if (ret2 != E_OK) {
-			ntstdio_printf(ntstdio, "get_tim\n");
+			printf("get_tim\n");
 			return;
 		}
@@ -953,5 +951,5 @@
 			memset(&s->dst, 0, sizeof(s->dst));
 			if ((ret = tcp_acp_cep(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {
-				ntstdio_printf(ntstdio, "tcp_acp_cep(%d) => %d\n", s->cepid, ret);
+				printf("tcp_acp_cep(%d) => %d\n", s->cepid, ret);
 				tslp_tsk(100 * 1000);	// TODO
 				s->state = STATE_CLOSING;
@@ -959,5 +957,5 @@
 			}
 			IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr);
-			ntstdio_printf(ntstdio, "connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
+			printf("connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
 			memset(&s->in, 0, sizeof(s->in));
 			memset(&s->out, 0, sizeof(s->out));
@@ -974,5 +972,5 @@
 			break;
 		case STATE_CLOSING:
-			ntstdio_printf(ntstdio, "close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
+			printf("close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
 			tcp_sht_cep(s->cepid);
 			tcp_cls_cep(s->cepid, TMO_FEVR);
