Index: asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.c	(revision 340)
+++ asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.c	(revision 374)
@@ -47,122 +47,8 @@
 #include "core/ntshell.h"
 #include "core/ntlibc.h"
-#include "util/ntstdio.h"
-
-extern ntstdio_t ntstdio;
+#include <stdio.h>
+#include <getopt.h>
+
 extern int ntshell_exit;
-
-extern int mbtowc(wchar_t *__restrict wc, const char *__restrict src, size_t n);
-
-/* musl_getopt from msul */
-char *optarg;
-int optind=1, opterr=1, optopt, optpos, optreset=0;
-extern int optind, opterr;
-
-static void ntstdio_write(ntstdio_t *handle, const char *str, int l)
-{
-	for (; *str && l >= 0; l--) {
-		ntstdio_putc(handle, *str++);
-	}
-}
-
-static void __getopt_msg(const char *a, const char *b, const char *c, size_t l)
-{
-	ntstdio_puts(&ntstdio, a);
-	ntstdio_write(&ntstdio, b, strlen(b));
-	ntstdio_write(&ntstdio, c, l);
-	ntstdio_putc(&ntstdio, '\n');
-}
-
-static int musl_getopt(int argc, char * const argv[], const char *optstring)
-{
-	int i;
-	wchar_t c, d;
-	int k, l;
-	char *optchar;
-
-	if (!optind || optreset) {
-		optreset = 0;
-		optpos = 0;
-		optind = 1;
-	}
-
-	if (optind >= argc || !argv[optind])
-		return -1;
-
-	if (argv[optind][0] != '-') {
-		if (optstring[0] == '-') {
-			optarg = argv[optind++];
-			return 1;
-		}
-		return -1;
-	}
-
-	if (!argv[optind][1])
-		return -1;
-
-	if (argv[optind][1] == '-' && !argv[optind][2])
-		return optind++, -1;
-
-	if (!optpos) optpos++;
-	if ((k = mbtowc(&c, argv[optind]+optpos, MB_LEN_MAX)) < 0) {
-		k = 1;
-		c = 0xfffd; /* replacement char */
-	}
-	optchar = argv[optind]+optpos;
-	optopt = c;
-	optpos += k;
-
-	if (!argv[optind][optpos]) {
-		optind++;
-		optpos = 0;
-	}
-
-	if (optstring[0] == '-' || optstring[0] == '+')
-		optstring++;
-
-	i = 0;
-	d = 0;
-	do {
-		l = mbtowc(&d, optstring+i, MB_LEN_MAX);
-		if (l>0) i+=l; else i++;
-	} while (l && d != c);
-
-	if (d != c) {
-		if (optstring[0] != ':' && opterr)
-			__getopt_msg(argv[0], ": unrecognized option: ", optchar, k);
-		return '?';
-	}
-	if (optstring[i] == ':') {
-		if (optstring[i+1] == ':') optarg = 0;
-		else if (optind >= argc) {
-			if (optstring[0] == ':') return ':';
-			if (opterr) __getopt_msg(argv[0],
-				": option requires an argument: ",
-				optchar, k);
-			return '?';
-		}
-		if (optstring[i+1] != ':' || optpos) {
-			optarg = argv[optind++] + optpos;
-			optpos = 0;
-		}
-	}
-	return c;
-}
-
-int shell_kill(int pid, int sig)
-{
-	DebugBreak();
-	return -1;
-}
-
-int shell_gettimeofday(struct timeval *tv, void *tzvp)
-{
-	SYSTIM time;
-	if (!tv) return 0;
-	get_tim(&time);
-	tv->tv_sec = time / 1000000;
-	tv->tv_usec = time - (tv->tv_sec * 1000000);
-	return 0;
-}
 
 void put_rc(const char *func, FRESULT rc)
@@ -178,5 +64,5 @@
 		while (*p++);
 	}
-	ntstdio_printf(&ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
+	printf("%s() =>%u FR_%s\n", func, (UINT)rc, p);
 }
 
@@ -190,5 +76,5 @@
 		while (*p++);
 	}
-	ntstdio_printf(&ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
+	printf("%s() =>%u %s\n", func, (UINT)rc, p);
 }
 
@@ -240,5 +126,5 @@
 
 	ntlibc_strlcat(path, "\n", sizeof(path));
-	ntstdio_printf(&ntstdio, path);
+	printf(path);
 
 	return 0;
@@ -252,5 +138,5 @@
 	char *fn;
 
-#if _USE_LFN
+#if FF_USE_LFN
 	fn = *fno->lfname ? fno->lfname : fno->fname;
 #else
@@ -263,5 +149,5 @@
 
 	if (list_option & LS_LONG) {
-		ntstdio_printf(&ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
+		printf("%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
 			(fno->fattrib & AM_DIR) ? 'd' : '-',
 			(fno->fattrib & AM_RDO) ? 'r' : '-',
@@ -277,20 +163,20 @@
 
 		if (fno->fattrib & AM_DIR) {                    /* It is a directory */
-			ntstdio_printf(&ntstdio, "%10S ", " ");
+			printf("%10s ", " ");
 		}
 		else {
-			ntstdio_printf(&ntstdio, "%10d ", fno->fsize);
+			printf("%10lu ", fno->fsize);
 		}
 	}
 
 	if (fno->fattrib & AM_DIR) {                    /* It is a directory */
-		ntstdio_printf(&ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
+		printf("\x1B[32m%s\x1B[0m\n", fn);
 	}
 	else {
-		ntstdio_printf(&ntstdio, "%s\n", fn);
-	}
-}
-
-#define LFN_BUF_SIZE (_MAX_LFN + 1)
+		printf("%s\n", fn);
+	}
+}
+
+#define LFN_BUF_SIZE (FF_MAX_LFN + 1)
 /* lsコマンド dir内 表示 */
 void print_ls(char *path_p, char *pattern_p, BYTE list_option)
@@ -298,5 +184,5 @@
 	FRESULT res;
 	FILINFO fno;
-	DIR dir;
+	FATFS_DIR dir;
 	char *fn;   /* This function assumes non-Unicode configuration */
 
@@ -307,13 +193,13 @@
 	path_backup = ff_memalloc(LFN_BUF_SIZE);
 	if (path_backup == NULL) {
-		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		printf("ff_memalloc err.\n");
 		return;
 	}
 
-#if _USE_LFN
+#if FF_USE_LFN
 	char *lfn = NULL;
 	lfn = ff_memalloc(LFN_BUF_SIZE);
 	if (lfn == NULL) {
-		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		printf("ff_memalloc err.\n");
 		ff_memfree(path_backup);
 		return;
@@ -333,6 +219,6 @@
 
 	while ((res == FR_OK) && (fno.fname[0] != 0)) {
-		if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* DIR とパターンマッチしている場合は DIR 内部を ls する */
-#if _USE_LFN
+		if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* FATFS_DIR とパターンマッチしている場合は FATFS_DIR 内部を ls する */
+#if FF_USE_LFN
 			fn = *fno.lfname ? fno.lfname : fno.fname;
 #else
@@ -351,9 +237,9 @@
 			}
 
-			ntstdio_printf(&ntstdio, "\n%s/%s:\n", path_p, fn);
+			printf("\n%s/%s:\n", path_p, fn);
 
 			print_ls(fn, NULL, list_option);
 
-			ntstdio_printf(&ntstdio, "\n");
+			printf("\n");
 
 			if ((res = f_chdrive(path_backup)) != FR_OK) {
@@ -384,9 +270,9 @@
 {
 	char *pattern_p = NULL, *basename_p = NULL, *dirname_p = NULL;
-	char default_pattern[_MAX_LFN] = "";
+	char default_pattern[FF_MAX_LFN] = "";
 	int c;
 	BYTE list_option = 0;
 
-	while ((c = musl_getopt(argc, argv, "al")) != -1) {
+	while ((c = getopt(argc, argv, "al")) != -1) {
 		switch (c) {
 		case 'a':
@@ -446,9 +332,9 @@
 		return 0;
 
-#if _USE_LFN
+#if FF_USE_LFN
 	/* LFN buffer alloc */
 	lfn = ff_memalloc(LFN_BUF_SIZE);
 	if (lfn == NULL) {
-		ntstdio_printf(&ntstdio, "alloc err.\n");
+		printf("alloc err.\n");
 		goto cp_end;
 	}
@@ -460,5 +346,5 @@
 	local_buff = ff_memalloc(64);
 	if (local_buff == NULL) {
-		ntstdio_printf(&ntstdio, "alloc err.\n");
+		printf("alloc err.\n");
 		goto cp_end;
 	}
@@ -470,7 +356,7 @@
 	if (res != FR_OK) {
 		if (res == FR_NO_FILE)
-			ntstdio_printf(&ntstdio, "src no file.\n", res);
+			printf("src no file.\n");
 		else
-			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+			printf("src stat err(%d).\n", res);
 		goto cp_end;
 	}
@@ -481,5 +367,5 @@
 		res = f_open(&src_fp, src_str_p, (FA_OPEN_EXISTING | FA_READ));
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "src open err(%d).\n", res);
+			printf("src open err(%d).\n", res);
 			goto cp_end;
 		}
@@ -496,17 +382,17 @@
 				dst_mod_str_p = ff_memalloc(LFN_BUF_SIZE);
 				if (dst_mod_str_p == NULL) {
-					ntstdio_printf(&ntstdio, "alloc err.\n");
+					printf("alloc err.\n");
 					goto cp_end;
 				}
-				ntstdio_snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
+				snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
 				dst_str_p = dst_mod_str_p;
 			}
 			else {
-				ntstdio_printf(&ntstdio, "dst file exists.\n");
+				printf("dst file exists.\n");
 				goto cp_end_1;
 			}
 		}
 		else {
-			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+			printf("src stat err(%d).\n", res);
 			goto cp_end_1;
 		}
@@ -514,5 +400,5 @@
 	res = f_open(&dst_fp, dst_str_p, (FA_CREATE_NEW | FA_WRITE));
 	if (res != FR_OK) {
-		ntstdio_printf(&ntstdio, "dst open err(%d).\n", res);
+		printf("dst open err(%d).\n", res);
 		goto cp_end_1;
 	}
@@ -525,5 +411,5 @@
 		res = f_read(&src_fp, local_buff, sizeof(local_buff), &read_size);
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "src read err(%d).\n", res);
+			printf("src read err(%d).\n", res);
 			goto cp_end_2;
 		}
@@ -532,9 +418,9 @@
 		res = f_write(&dst_fp, local_buff, read_size, &write_size);
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "dst write err(%d).\n", res);
+			printf("dst write err(%d).\n", res);
 			goto cp_end_2;
 		}
 		if (read_size != write_size) {
-			ntstdio_printf(&ntstdio, "dst write err(disk full).\n", res);
+			printf("dst write err(disk full).\n");
 			goto cp_end_2;
 		}
@@ -622,13 +508,13 @@
 	unsigned int op_offset = 0, op_size = 0, op_end = 0;
 
-	while ((op = musl_getopt(argc, argv, "hduos0123456789xX")) != -1) {
+	while ((op = getopt(argc, argv, "hduos0123456789xX")) != -1) {
 		switch (op) {
 		case 'h': /* help */
-			ntstdio_printf(&ntstdio, " hexdump [OPTION] file\n");
-			ntstdio_printf(&ntstdio, "  -h : help\n");
-			ntstdio_printf(&ntstdio, "  -d : print all byte with convert and color [in character area] (default)\n");
-			ntstdio_printf(&ntstdio, "  -u : try print UTF-8 code [in character area]\n");
-			ntstdio_printf(&ntstdio, "  -oOFFSET : print start offset address from top\n");
-			ntstdio_printf(&ntstdio, "  -sSIZE   : print size\n");
+			printf(" hexdump [OPTION] file\n");
+			printf("  -h : help\n");
+			printf("  -d : print all byte with convert and color [in character area] (default)\n");
+			printf("  -u : try print UTF-8 code [in character area]\n");
+			printf("  -oOFFSET : print start offset address from top\n");
+			printf("  -sSIZE   : print size\n");
 			break;
 		case 'd': /* print one byte character [in character area] (default) */
@@ -661,5 +547,5 @@
 	/* position adjusting */
 	if (op_offset >= fsrc.fsize) {
-		ntstdio_printf(&ntstdio, "error : input offset is bigger than file size(0x%X).\n", fsrc.fsize);
+		printf("error : input offset is bigger than file size(0x%lX).\n", fsrc.fsize);
 		return 0;
 	}
@@ -674,5 +560,5 @@
 		char *pos = line;
 		int rst = sizeof(line);
-		int len = ntstdio_snprintf(pos, rst, "%08X: ", i);
+		int len = snprintf(pos, rst, "%08X: ", i);
 		pos += len;
 		rst -= len;
@@ -693,7 +579,7 @@
 			char c = data[j];
 			if (j != 7)
-				len = ntstdio_snprintf(pos, rst, "%02X ", c);
+				len = snprintf(pos, rst, "%02X ", c);
 			else
-				len = ntstdio_snprintf(pos, rst, "%02X-", c);
+				len = snprintf(pos, rst, "%02X-", c);
 			pos += len;
 			rst -= len;
@@ -723,7 +609,7 @@
 								break;
 							if (j + k != 7)
-								len = ntstdio_snprintf(pos, rst, "%02X ", data[j + k]);
+								len = snprintf(pos, rst, "%02X ", data[j + k]);
 							else
-								len = ntstdio_snprintf(pos, rst, "%02X-", data[j + k]);
+								len = snprintf(pos, rst, "%02X-", data[j + k]);
 							pos += len;
 							rst -= len;
@@ -743,5 +629,5 @@
 				apos += len;
 				arst -= len;
-				len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
+				len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
 				utf8_odd_bytes--;
 			}
@@ -763,5 +649,5 @@
 					c = '?';
 				}
-				len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
+				len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
 			}
 
@@ -772,16 +658,16 @@
 		for (int j = br; j < 16; j++) {
 			if (j != 7)
-				len = ntstdio_snprintf(pos, rst, "   ");
+				len = snprintf(pos, rst, "   ");
 			else
-				len = ntstdio_snprintf(pos, rst, "  -");
+				len = snprintf(pos, rst, "  -");
 			pos += len;
 			rst -= len;
 		}
 
-		len = ntstdio_snprintf(pos, rst, ": %s\n", ascii);
+		len = snprintf(pos, rst, ": %s\n", ascii);
 		pos += len;
 		rst -= len;
 
-		ntstdio_puts(&ntstdio, line);
+		puts(line);
 	}
 
@@ -796,7 +682,7 @@
 	char buf[30];
 
-	ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
+	ret = clock_gettime(CLOCK_REALTIME, &tp);
 	if (ret != 0) {
-		ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
+		printf("clock_gettime error %d", ret);
 		return 0;
 	}
@@ -804,5 +690,5 @@
 	memset(buf, 0, sizeof(buf));
 	if (ctime_r(&tp.tv_sec, buf) == NULL) {
-		ntstdio_printf(&ntstdio, "ctime_r error");
+		printf("ctime_r error");
 		return 0;
 	}
@@ -812,5 +698,5 @@
 	buf[ret - 1] = '\0';
 
-	ntstdio_printf(&ntstdio, "%s .%09u\n", buf, tp.tv_nsec);
+	printf("%s .%09ld\n", buf, tp.tv_nsec);
 	return 0;
 }
@@ -819,10 +705,10 @@
 {
 	if (argc != 2) {
-		ntstdio_printf(&ntstdio, "info sys\n");
-		ntstdio_printf(&ntstdio, "info ver\n");
+		printf("info sys\n");
+		printf("info ver\n");
 		return 0;
 	}
 	if (strcmp(argv[1], "sys") == 0) {
-		ntstdio_printf(&ntstdio, TARGET_NAME" Monitor\n");
+		printf(TARGET_NAME" Monitor\n");
 		return 0;
 	}
@@ -830,8 +716,8 @@
 		int mj, mn, bd;
 		ntshell_version(&mj, &mn, &bd);
-		ntstdio_printf(&ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
-		return 0;
-	}
-	ntstdio_printf(&ntstdio, "Unknown sub command found\n");
+		printf("Version %d.%d.%d\n", mj, mn, bd);
+		return 0;
+	}
+	printf("Unknown sub command found\n");
 	return -1;
 }
Index: asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.h
===================================================================
--- asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.h	(revision 340)
+++ asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.h	(revision 374)
@@ -56,8 +56,4 @@
 int usrcmd_exit(int argc, char **argv);
 
-void shell_abort();
-void shell_exit(int exitcd);
-int shell_kill(int pid, int sig);
-
 #endif
 
Index: asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.h
===================================================================
--- asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.h	(revision 340)
+++ asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.h	(revision 374)
@@ -78,4 +78,5 @@
 	int pos;
 	unsigned int option;
+	void *exinf;
 } ntstdio_t;
 
