summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/hwemul/tools/hwemul_tool.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-01-29 23:58:45 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2013-01-29 23:58:45 +0000
commit9d2631854c2131ad0f79962500771f5e085d66b1 (patch)
tree55d293ec17fff2ed8487c32bca42a672f34f7872 /utils/imxtools/hwemul/tools/hwemul_tool.c
parent6d5b1b2448043f34ba0bbafce7ea1768cc5a79a7 (diff)
downloadrockbox-9d2631854c2131ad0f79962500771f5e085d66b1.tar.gz
rockbox-9d2631854c2131ad0f79962500771f5e085d66b1.zip
imxtools/hwemul: add readline support
Change-Id: If2e86bf8b520a8d4c38a56ac969918fdeb2c6f91
Diffstat (limited to 'utils/imxtools/hwemul/tools/hwemul_tool.c')
-rw-r--r--utils/imxtools/hwemul/tools/hwemul_tool.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/utils/imxtools/hwemul/tools/hwemul_tool.c b/utils/imxtools/hwemul/tools/hwemul_tool.c
index c6056edf96..d75cd7a957 100644
--- a/utils/imxtools/hwemul/tools/hwemul_tool.c
+++ b/utils/imxtools/hwemul/tools/hwemul_tool.c
@@ -24,6 +24,8 @@
#include <string.h>
#include <getopt.h>
#include <stdbool.h>
+#include <readline/readline.h>
+#include <readline/history.h>
bool g_quiet = false;
struct hwemul_device_t hwdev;
@@ -326,22 +328,20 @@ int parse_command(char *cmd)
return syntax_error(cmd);
}
-int do_command()
+void interactive_mode(void)
{
- char *line = NULL;
- int size = 0;
- getline(&line, &size, stdin);
- char *end = strchr(line, '\n');
- if(end)
- *end = 0;
- char *pch = strtok(line, " ");
- int ret;
- if(pch)
- ret = parse_command(pch);
- else
- ret = print_help();
- free(line);
- return ret;
+ rl_bind_key('\t', rl_complete);
+ while(1)
+ {
+ char *input = readline("> ");
+ if(!input)
+ break;
+ add_history(input);
+ int ret = parse_command(input);
+ free(input);
+ if(ret == 0)
+ break;
+ }
}
void usage(void)
@@ -543,9 +543,9 @@ int main(int argc, char **argv)
if(!g_quiet)
printf("Starting interactive session. Type 'help' to get help.\n");
- while(1)
- if(!do_command())
- break;
+
+ interactive_mode();
+
Lerr:
if(features.feature_mask & HWEMUL_FEATURE_LOG)
{