changeset 1027:1178befeda76

fc-shell: tch command framework started
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 30 May 2016 23:19:30 +0000
parents f511bbac0efa
children 71bbddbcc6a1
files rvinterf/asyncshell/tchcmd.c rvinterf/asyncshell/usercmd.c
diffstat 2 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/asyncshell/tchcmd.c	Mon May 30 22:45:48 2016 +0000
+++ b/rvinterf/asyncshell/tchcmd.c	Mon May 30 23:19:30 2016 +0000
@@ -118,3 +118,54 @@
 		goto inv;
 	}
 }
+
+static void
+cmd_tch_dumpraw(argc, argv)
+	char **argv;
+{
+	if (argc < 2) {
+		printf("error: too few arguments\n");
+		return;
+	}
+	if (!strcmp(argv[1], "enable") || !strcmp(argv[1], "on") ||
+	    !strcmp(argv[1], "1"))
+		tch_rawdump_mode = 1;
+	else if (!strcmp(argv[1], "disable") || !strcmp(argv[1], "off") ||
+		 !strcmp(argv[1], "0"))
+		tch_rawdump_mode = 0;
+	else
+		printf("error: boolean argument required\n");
+}
+
+static void
+cmd_tch_status(argc, argv)
+	char **argv;
+{
+	if (argc > 1) {
+		printf("error: too many arguments\n");
+		return;
+	}
+	printf("TCH raw dump mode is %s\n",
+		tch_rawdump_mode ? "enabled" : "disabled");
+}
+
+void
+cmd_tch_dispatch(argstr)
+	char *argstr;
+{
+	char *argv[3];
+	int argc, rc;
+
+	rc = parse_interactive_command_into_argv(argstr, argv, 1, 2, &argc);
+	if (rc < 0)
+		return;
+	if (!strcmp(argv[0], "dump-raw")) {
+		cmd_tch_dumpraw(argc, argv);
+		return;
+	}
+	if (!strcmp(argv[0], "status")) {
+		cmd_tch_status(argc, argv);
+		return;
+	}
+	printf("error: invalid tch subcommand\n");
+}
--- a/rvinterf/asyncshell/usercmd.c	Mon May 30 22:45:48 2016 +0000
+++ b/rvinterf/asyncshell/usercmd.c	Mon May 30 23:19:30 2016 +0000
@@ -17,6 +17,7 @@
 extern void cmd_sendat();
 extern void cmd_send_interactive();
 extern void cmd_sp_interactive();
+extern void cmd_tch_dispatch();
 extern void cmd_tchdl_interactive();
 extern void cmd_tgtreset();
 
@@ -39,6 +40,7 @@
 	{"send", cmd_send_interactive},
 	{"sp", cmd_sp_interactive},
 	{"str", cmd_sendat},
+	{"tch", cmd_tch_dispatch},
 	{"tch-dl", cmd_tchdl_interactive},
 	{"tgtreset", cmd_tgtreset},
 	{0, 0}