Index: EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c	(revision 331)
@@ -57,4 +57,17 @@
 }
 
+int ntlibc_strlcpy(char *des, const char *src, int n)
+{
+	char *d = des, *e = &des[n];
+	const char *s = src;
+	while (*s && d < e) {
+		*d = *s;
+		d++;
+		s++;
+	}
+	*d++ = '\0';
+	return (int)d - (int)des;
+}
+
 char *ntlibc_strcat(char *des, const char *src)
 {
@@ -71,4 +84,20 @@
 	*d = '\0';
 	return des;
+}
+
+int ntlibc_strlcat(char *des, const char *src, int n)
+{
+	char *d = des, *e = &des[n];
+	const char *s = src;
+	while (*d && d < e) {
+		d++;
+	}
+	while (*s && d < e) {
+		*d = *s;
+		d++;
+		s++;
+	}
+	*d++ = '\0';
+	return (int)d - (int)des;
 }
 
@@ -223,4 +252,49 @@
 }
 
+unsigned long ntlibc_strtoul(const char *restrict nptr, char **restrict endptr, int base)
+{
+	int cnt;
+	int num = 0;
+	int ofs = 0;
+	int sign = 0;
+	int scnt = 0;
+	char *p = (char *)nptr;
+	while (*p != '\0') {
+		if (!ntlibc_isdigit(*p)) {
+			if (*p == ' ') {
+				ofs++;
+			}
+			if (*p == '+') {
+				sign = 0;
+				ofs++;
+				if (scnt++ > 0) {
+					*endptr = p;
+					break;
+				}
+			}
+			if (*p == '-') {
+				sign = 1;
+				ofs++;
+				if (scnt++ > 0) {
+					*endptr = p;
+					break;
+				}
+			}
+			*endptr = p;
+			break;
+		}
+		p++;
+	}
+	for (cnt = ofs; (nptr[cnt] >= '0') && (nptr[cnt] <= '9'); cnt++) {
+		num = 10 * num + (nptr[cnt] - '0');
+	}
+	if (sign) {
+		return -num;
+	}
+	else {
+		return num;
+	}
+}
+
 char *ntlibc_strchr(const char *s, int c)
 {
Index: EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h	(revision 331)
@@ -40,5 +40,7 @@
 int ntlibc_strlen(const char *s);
 char *ntlibc_strcpy(char *des, const char *src);
+int ntlibc_strlcpy(char *des, const char *src, int n);
 char *ntlibc_strcat(char *des, const char *src);
+int ntlibc_strlcat(char *des, const char *src, int n);
 int ntlibc_strcmp(const char *s1, const char *s2);
 int ntlibc_stricmp(const char *s1, const char *s2);
@@ -50,4 +52,5 @@
 int ntlibc_tolower(int c);
 int ntlibc_atoi(const char *nptr);
+unsigned long ntlibc_strtoul(const char *__restrict nptr, char **__restrict endptr, int base);
 char *ntlibc_strchr(const char *s, int c);
 char *ntlibc_utoa(unsigned int value, char *s, int radix);
Index: EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c	(revision 331)
@@ -33,4 +33,5 @@
 #include <string.h>
 #include "ntshell.h"
+#include "core/ntlibc.h"
 
 int ntshell_exit;
@@ -107,5 +108,5 @@
  * @param HANDLE A pointer of the handle.
  */
-#define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, strlen((HANDLE)->prompt))
+#define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, ntlibc_strlen((HANDLE)->prompt))
 
 /**
@@ -114,5 +115,5 @@
  * @param HANDLE A pointer of the handle.
  */
-#define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, strlen(NTSHELL_PROMPT_NEWLINE))
+#define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, ntlibc_strlen(NTSHELL_PROMPT_NEWLINE))
 
 /**
@@ -399,5 +400,5 @@
 				 * Found the suggestion.
 				 */
-				int n = strlen((const char *)buf);
+				int n = ntlibc_strlen((const char *)buf);
 				VTSEND_ERASE_LINE(ntshell);
 				VTSEND_CURSOR_HEAD(ntshell);
@@ -429,5 +430,5 @@
 			 * Found the suggestion.
 			 */
-			int n = strlen((const char *)buf);
+			int n = ntlibc_strlen((const char *)buf);
 			VTSEND_ERASE_LINE(ntshell);
 			VTSEND_CURSOR_HEAD(ntshell);
@@ -441,5 +442,5 @@
 			 * Recall the previous input text string.
 			 */
-			int n = strlen(SUGGEST_SOURCE(ntshell));
+			int n = ntlibc_strlen(SUGGEST_SOURCE(ntshell));
 			VTSEND_ERASE_LINE(ntshell);
 			VTSEND_CURSOR_HEAD(ntshell);
@@ -484,5 +485,5 @@
 	UNUSED_VARIABLE(ch);
 	text_editor_get_text(GET_EDITOR(ntshell), buf, sizeof(buf));
-	len = strlen((const char *)buf);
+	len = ntlibc_strlen((const char *)buf);
 	VTSEND_CURSOR_HEAD(ntshell);
 	PROMPT_WRITE(ntshell);
@@ -606,5 +607,5 @@
 	p->func_callback = func_callback;
 	p->extobj = extobj;
-	strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
+	ntlibc_strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
 
 	p->vtrecv.user_data = p;
@@ -666,5 +667,5 @@
 	}
 
-	strcpy(p->prompt, prompt);
+	ntlibc_strcpy(p->prompt, prompt);
 }
 
Index: EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c	(revision 331)
@@ -33,4 +33,5 @@
 #include <string.h>
 #include "text_history.h"
+#include "core/ntlibc.h"
 
 /**
@@ -145,5 +146,5 @@
 	char *buf, const int siz)
 {
-	const int text_len = strlen((const char *)text);
+	const int text_len = ntlibc_strlen((const char *)text);
 	int found = 0;
 	int i;
@@ -151,14 +152,14 @@
 		int target = (p->rp + i) % TEXTHISTORY_DEPTH;
 		char *txtp = p->history + (TEXTHISTORY_MAXLEN * target);
-		const int target_len = strlen((const char *)txtp);
+		const int target_len = ntlibc_strlen((const char *)txtp);
 		int comp_len = (target_len < text_len) ? target_len : text_len;
-		if ((strncmp(
+		if ((ntlibc_strncmp(
 			(const char *)txtp,
 			(const char *)text, comp_len) == 0) && (comp_len > 0)) {
 			if (found == index) {
-				if (siz <= strlen(txtp)) {
+				if (siz <= ntlibc_strlen(txtp)) {
 					return -1;
 				}
-				strcpy((char *)buf, (char *)txtp);
+				ntlibc_strcpy((char *)buf, (char *)txtp);
 				return 0;
 			}
Index: EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 331)
@@ -31,12 +31,10 @@
  */
 
+#include "shellif.h"
 #include <kernel.h>
+#include <string.h>
 #include <t_syslog.h>
 #include <t_stdlib.h>
 #include <sil.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <setjmp.h>
 #include "syssvc/syslog.h"
 #include "kernel_cfg.h"
@@ -46,9 +44,106 @@
 #include "ff.h"
 #include "usrcmd.h"
-#include "ntstdio.h"
-#include "ntshell.h"
+#include "core/ntshell.h"
+#include "core/ntlibc.h"
+#include "util/ntstdio.h"
 
 extern ntstdio_t ntstdio;
 extern int ntshell_exit;
+
+/* 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, ntlibc_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)
@@ -99,5 +194,5 @@
 	size_t i, j;
 	if (!s || !*s) return ".";
-	i = strlen(s) - 1;
+	i = ntlibc_strlen(s) - 1;
 	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
 	for (; i&&s[i] == '/'; i--) s[i] = 0;
@@ -111,5 +206,5 @@
 	size_t i, j;
 	if (!s || !*s) return ".";
-	i = strlen(s) - 1;
+	i = ntlibc_strlen(s) - 1;
 	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
 	for (; s[i] == '/'; i--) if (!i) return (s == _s) ? "/" : _s;
@@ -141,5 +236,5 @@
 	}
 
-	strlcat(path, "\n", sizeof(path));
+	ntlibc_strlcat(path, "\n", sizeof(path));
 	ntstdio_printf(&ntstdio, path);
 
@@ -287,29 +382,27 @@
 	char *pattern_p = NULL, *basename_p = NULL, *dirname_p = NULL;
 	char default_pattern[_MAX_LFN] = "";
-	int i;
+	int c;
 	BYTE list_option = 0;
 
-	for (i = 1; i < argc; i++) {
-		if (argv[i][0] == '-') {
-			if (argv[i][1] == 'a') {
-				list_option |= LS_ALL;
-			}
-			else if (argv[i][1] == 'l') {
-				list_option |= LS_LONG;
-			}
-			continue;
-		}
-		if (argv[i][0] != '\0') {	/* pattern matching ? */
-			pattern_p = &argv[i][0];
+	while ((c = musl_getopt(argc, argv, "al")) != -1) {
+		switch (c) {
+		case 'a':
+			list_option |= LS_ALL;
 			break;
-		}
-	}
+		case 'l':
+			list_option |= LS_LONG;
+			break;
+		default:
+			break;
+		}
+	}
+	pattern_p = *(argv + optind);
 
 	if (pattern_p != NULL)
-		strlcpy(default_pattern, pattern_p, sizeof(default_pattern));
+		ntlibc_strlcpy(default_pattern, pattern_p, sizeof(default_pattern));
 	basename_p = basename(pattern_p);
 	dirname_p = dirname(default_pattern);
 	if (((dirname_p[0] == '/') && (basename_p[0] == '/')) ||
-		(!strncmp(dirname_p, ".", strlen(dirname_p)) && !strncmp(basename_p, ".", strlen(basename_p))))
+		(!ntlibc_strncmp(dirname_p, ".", ntlibc_strlen(dirname_p)) && !ntlibc_strncmp(basename_p, ".", ntlibc_strlen(basename_p))))
 	{
 		basename_p = NULL;
@@ -499,22 +592,81 @@
 }
 
+extern WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
+extern void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
+#define HEXDUMP_EXTRA_FOR_UTF8 3 /* need extra buffer size */
+#define CCOLOR_RESET	0
+#define CCOLOR_BLACK	30
+#define CCOLOR_RED		31
+#define CCOLOR_GREEN	32
+#define CCOLOR_YELLOW	33
+#define CCOLOR_BLUE		34
+#define CCOLOR_MAGENTA	35
+#define CCOLOR_CYAN		36
+#define CCOLOR_WHITE	37
+enum {
+	HEXDUMP_OPT_DEFAULT = 1 << 0,
+	HEXDUMP_OPT_UTF8 = 1 << 1,
+};
+
 int usrcmd_hexdump(int argc, char **argv)
 {
 	FRESULT res;
 	FIL fsrc;
-	unsigned char data[16 + 1];
-	unsigned char ascii[sizeof("\x1B[31m0\x1B[0m\x1B[31m1\x1B[0m\x1B[31m2\x1B[0m\x1B[31m3\x1B[0m\x1B[31m4\x1B[0m\x1B[31m5\x1B[0m\x1B[31m6\x1B[0m\x1B[31m7\x1B[0m\x1B[31m8\x1B[0m\x1B[31m9\x1B[0m\x1B[31ma\x1B[0m\x1B[31mb\x1B[0m\x1B[31mc\x1B[0m\x1B[31md\x1B[0m\x1B[31me\x1B[0m\x1B[31mf\x1B[0m")];
+	unsigned char data[16 + 1 + HEXDUMP_EXTRA_FOR_UTF8];
+	unsigned char ascii[sizeof("\x1B[31m0\x1B[0m\x1B[31m1\x1B[0m\x1B[31m2\x1B[0m\x1B[31m3\x1B[0m\x1B[31m4\x1B[0m\x1B[31m5\x1B[0m\x1B[31m6\x1B[0m\x1B[31m7\x1B[0m\x1B[31m8\x1B[0m\x1B[31m9\x1B[0m\x1B[31ma\x1B[0m\x1B[31mb\x1B[0m\x1B[31mc\x1B[0m\x1B[31md\x1B[0m\x1B[31me\x1B[0m\x1B[31mf\x1B[0m") + HEXDUMP_EXTRA_FOR_UTF8];
 	char line[sizeof("00000000: 00 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00 : \n") + sizeof(ascii)];
-
-	if (argc != 2) {
-		ntstdio_printf(&ntstdio, "hexdump file\n");
-	}
-
-	if ((res = f_open(&fsrc, argv[1], FA_OPEN_EXISTING | FA_READ)) != FR_OK) {
+	TCHAR *filename_p = NULL;
+	int op, option_flag = HEXDUMP_OPT_DEFAULT;
+	char *option_ptr, *option_endptr, ccolor, utf8_done_flg, utf8_odd_bytes = 0;
+	unsigned int op_offset = 0, op_size = 0, op_end = 0;
+
+	while ((op = musl_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");
+			break;
+		case 'd': /* print one byte character [in character area] (default) */
+			option_flag |= HEXDUMP_OPT_DEFAULT;
+			break;
+		case 'u': /* try print UTF-8 code [in character area] */
+			option_flag |= HEXDUMP_OPT_UTF8;
+			break;
+		case 'o': /* print start offset address from top */
+			option_ptr = *(argv + optind);
+			op_offset = ntlibc_strtoul(&option_ptr[2], &option_endptr, 0);
+			break;
+		case 's': /* print size */
+			option_ptr = *(argv + optind);
+			op_size = ntlibc_strtoul(&option_ptr[2], &option_endptr, 0);
+			break;
+		default:
+			break;
+		}
+	}
+	filename_p = *(argv + optind);
+	if (filename_p == NULL)
+		return 0;
+
+	if ((res = f_open(&fsrc, filename_p, FA_OPEN_EXISTING | FA_READ)) != FR_OK) {
 		put_rc("f_open", res);
 		return 0;
 	}
 
-	for (int i = 0; i < fsrc.fsize; i += 16) {
+	/* position adjusting */
+	if (op_offset >= fsrc.fsize) {
+		ntstdio_printf(&ntstdio, "error : input offset is bigger than file size(0x%X).\n", fsrc.fsize);
+		return 0;
+	}
+	op_end = op_offset + op_size;
+	if ((op_size == 0) || (op_end >= fsrc.fsize))
+		op_end = fsrc.fsize;
+	f_lseek(&fsrc, op_offset);
+
+	for (int i = op_offset; i < op_end; i += 16) {
 		ascii[0] = '\0';
 		line[0] = '\0';
@@ -526,10 +678,12 @@
 
 		UINT br = 0;
-		if ((res = f_read(&fsrc, data, 16, &br)) != FR_OK) {
+		if ((res = f_read(&fsrc, data, 16 + HEXDUMP_EXTRA_FOR_UTF8, &br)) != FR_OK) {
 			put_rc("f_read", res);
 			f_close(&fsrc);
 			return 0;
 		}
-		data[16] = '\0';
+		data[br] = '\0';
+		f_lseek(&fsrc, i + 16);
+		if (br > 16) br = 16;
 
 		char *apos = ascii;
@@ -544,13 +698,71 @@
 			rst -= len;
 
+			len = 0;
+			utf8_done_flg = 0;
+			ccolor = CCOLOR_RESET;
+
 			if (c < 0x20) {
-				len = ntstdio_snprintf(apos, arst , "\x1B[31m%c\x1B[0m", c + 0x40);
-			}
-			else if (c == 0xFF) {
-				len = ntstdio_snprintf(apos, arst, "\x1B[32m%c\x1B[0m", 'E');
+				ccolor = CCOLOR_RED;
+				c = c + 0x40;
 			}
 			else {
-				len = ntstdio_snprintf(apos, arst, "%c", c);
-			}
+				if (option_flag & HEXDUMP_OPT_UTF8) { /* try UTF-8 */
+					/* check character code */
+					int bf_utf8_bytes, af_utf8_bytes;
+					unsigned char utf8_code[4];
+					WCHAR utf16_code;
+
+					utf16_code = Utf8_to_Utf16(&data[j], &bf_utf8_bytes);       /* try UTF-8 -> UTF-16 */
+					Utf16_to_Utf8(utf8_code, &af_utf8_bytes, (UINT)utf16_code); /* try UTF-16 -> UTF-8 */
+					if ((af_utf8_bytes <= 3 && bf_utf8_bytes == af_utf8_bytes) &&
+						!memcmp(&data[j], utf8_code, af_utf8_bytes)) { /* size & code match */
+						utf8_done_flg = 1;
+						for (int k = 1; k < af_utf8_bytes; k++) { /* pos */
+							if (j + k >= 16)
+								break;
+							if (j + k != 7)
+								len = ntstdio_snprintf(pos, rst, "%02X ", data[j + k]);
+							else
+								len = ntstdio_snprintf(pos, rst, "%02X-", data[j + k]);
+							pos += len;
+							rst -= len;
+						}
+						memcpy(apos, &data[j], af_utf8_bytes); /* apos */
+						apos[af_utf8_bytes] = 0;
+						len = af_utf8_bytes;
+						j += af_utf8_bytes - 1;
+						if (af_utf8_bytes > 1) {
+							utf8_odd_bytes = j < 15 ? af_utf8_bytes - 2 : af_utf8_bytes - 1;
+						}
+					}
+				}
+			}
+
+			if (utf8_odd_bytes > 0 && j < 15) {
+				apos += len;
+				arst -= len;
+				len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
+				utf8_odd_bytes--;
+			}
+			else if (utf8_done_flg == 0) {
+				if (c >= 0x80 && c < 0x9F) {
+					ccolor = CCOLOR_RED;
+					c = c - 0x60;
+				}
+				else if (c >= 0xA0 && c < 0xDF) {
+					ccolor = CCOLOR_GREEN;
+					c = c - 0x60;
+				}
+				else if (c >= 0xE0 && c < 0xFF) {
+					ccolor = CCOLOR_GREEN;
+					c = c - 0xC0;
+				}
+				else if (c == 0x7F || c == 0x9F || c == 0xDF || c == 0xFF) {
+					ccolor = CCOLOR_CYAN;
+					c = '?';
+				}
+				len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
+			}
+
 			apos += len;
 			arst -= len;
@@ -570,5 +782,5 @@
 		rst -= len;
 
-		ntstdio_printf(&ntstdio, line);
+		ntstdio_puts(&ntstdio, line);
 	}
 
@@ -584,9 +796,9 @@
 		return 0;
 	}
-	if (strcmp(argv[1], "sys") == 0) {
+	if (ntlibc_strcmp(argv[1], "sys") == 0) {
 		ntstdio_printf(&ntstdio, "GR-PEACH Monitor\n");
 		return 0;
 	}
-	if (strcmp(argv[1], "ver") == 0) {
+	if (ntlibc_strcmp(argv[1], "ver") == 0) {
 		int mj, mn, bd;
 		ntshell_version(&mj, &mn, &bd);
Index: EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 331)
@@ -43,20 +43,20 @@
 } cmd_table_t;
 
-extern int usrcmd_cd(int argc, char **argv);
-extern int usrcmd_ls(int argc, char **argv);
-extern int usrcmd_cp(int argc, char **argv);
-extern int usrcmd_rm(int argc, char **argv);
-extern int usrcmd_mv(int argc, char **argv);
-extern int usrcmd_mkdir(int argc, char **argv);
-extern int usrcmd_hexdump(int argc, char **argv);
+int usrcmd_cd(int argc, char **argv);
+int usrcmd_ls(int argc, char **argv);
+int usrcmd_cp(int argc, char **argv);
+int usrcmd_rm(int argc, char **argv);
+int usrcmd_mv(int argc, char **argv);
+int usrcmd_mkdir(int argc, char **argv);
+int usrcmd_hexdump(int argc, char **argv);
 
-extern int usrcmd_help(int argc, char **argv);
-extern int usrcmd_info(int argc, char **argv);
-extern int usrcmd_exit(int argc, char **argv);
+int usrcmd_help(int argc, char **argv);
+int usrcmd_info(int argc, char **argv);
+int usrcmd_exit(int argc, char **argv);
 
-extern void shell_abort();
-extern void shell_exit(int exitcd);
-extern int shell_kill(int pid, int sig);
-extern int shell_gettimeofday(struct timeval * tp, void * tzvp);
+void shell_abort();
+void shell_exit(int exitcd);
+int shell_kill(int pid, int sig);
+int shell_gettimeofday(struct timeval * tp, void * tzvp);
 
 #endif
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c	(revision 331)
@@ -131,5 +131,5 @@
 	int argc;
 	char argv[NTOPT_TEXT_MAXLEN];
-	char *argvp[NTOPT_TEXT_MAXARGS];
+	char *argvp[1 + NTOPT_TEXT_MAXARGS];
 	int i;
 	int total;
@@ -146,5 +146,5 @@
 	for (i = 0; i < argc; i++) {
 		int len;
-		argvp[i] = ntopt_get_text(
+		argvp[i + 1] = ntopt_get_text(
 			str, i, p, NTOPT_TEXT_MAXLEN - total, &len);
 		if (total + len + 1 < NTOPT_TEXT_MAXLEN) {
@@ -156,5 +156,6 @@
 		}
 	}
+	argvp[0] = (char *)argc;
 
-	return func(argc, &argvp[0], extobj);
+	return func((long *)&argvp[0], extobj);
 }
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h	(revision 331)
@@ -55,5 +55,5 @@
  * @return A return value.
  */
-typedef int (*NTOPT_CALLBACK)(int argc, char **argv, void *extobj);
+typedef int (*NTOPT_CALLBACK)(long *args, void *extobj);
 
 #ifdef __cplusplus
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 331)
@@ -241,5 +241,5 @@
 
 	if (handle->xo) {
-		handle->xo((unsigned char)c);
+		handle->xo(handle, (unsigned char)c);
 	}
 	handle->pos++;
@@ -266,5 +266,5 @@
 void ntstdio_fputs(ntstdio_t *handle, NTSTDIO_XO xo, const char *str)
 {
-	void(*pf)(unsigned char);
+	NTSTDIO_XO pf;
 
 	/* Save current output device */
@@ -314,5 +314,5 @@
 	int result;
 	va_list arp;
-	void(*pf)(unsigned char);
+	NTSTDIO_XO pf;
 
 	/* Save current output device */
@@ -334,5 +334,5 @@
 	extern void shell_exit(int cd);
 
-	int c = handle->xi();
+	int c = handle->xi(handle);
 	if (handle->option & NTSTDIO_OPTION_LF_CR) {
 		if (c == '\r')
@@ -362,5 +362,5 @@
 	for (;;) {
 		/* Get a char from the incoming stream */
-		c = handle->xi();
+		c = handle->xi(handle);
 		if (!c) {
 			/* End of stream */
@@ -398,5 +398,5 @@
 int ntstdio_fgets(ntstdio_t *handle, NTSTDIO_XI xi, char *buf, int len)
 {
-	unsigned char(*pf)(void);
+	NTSTDIO_XI pf;
 	int n;
 
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 321)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 331)
@@ -67,14 +67,14 @@
 #define NTSTDIO_OPTION_LF_CR        (1 << 3)
 
-typedef unsigned char (*NTSTDIO_XI)(void);
-typedef void (*NTSTDIO_XO)(unsigned char c);
+typedef unsigned char (*NTSTDIO_XI)(struct ntstdio_t *handle);
+typedef void (*NTSTDIO_XO)(struct ntstdio_t *handle, unsigned char c);
 
-typedef struct {
-    NTSTDIO_XI xi;
-    NTSTDIO_XO xo;
-    char *outptr;
+typedef struct ntstdio_t {
+	NTSTDIO_XI xi;
+	NTSTDIO_XO xo;
+	char *outptr;
 	int len;
 	int pos;
-    unsigned int option;
+	unsigned int option;
 } ntstdio_t;
 
