summaryrefslogtreecommitdiff
path: root/utils/imxtools/hwemul/tools/hwemul_tool.c
diff options
context:
space:
mode:
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 @@
24#include <string.h> 24#include <string.h>
25#include <getopt.h> 25#include <getopt.h>
26#include <stdbool.h> 26#include <stdbool.h>
27#include <readline/readline.h>
28#include <readline/history.h>
27 29
28bool g_quiet = false; 30bool g_quiet = false;
29struct hwemul_device_t hwdev; 31struct hwemul_device_t hwdev;
@@ -326,22 +328,20 @@ int parse_command(char *cmd)
326 return syntax_error(cmd); 328 return syntax_error(cmd);
327} 329}
328 330
329int do_command() 331void interactive_mode(void)
330{ 332{
331 char *line = NULL; 333 rl_bind_key('\t', rl_complete);
332 int size = 0; 334 while(1)
333 getline(&line, &size, stdin); 335 {
334 char *end = strchr(line, '\n'); 336 char *input = readline("> ");
335 if(end) 337 if(!input)
336 *end = 0; 338 break;
337 char *pch = strtok(line, " "); 339 add_history(input);
338 int ret; 340 int ret = parse_command(input);
339 if(pch) 341 free(input);
340 ret = parse_command(pch); 342 if(ret == 0)
341 else 343 break;
342 ret = print_help(); 344 }
343 free(line);
344 return ret;
345} 345}
346 346
347void usage(void) 347void usage(void)
@@ -543,9 +543,9 @@ int main(int argc, char **argv)
543 543
544 if(!g_quiet) 544 if(!g_quiet)
545 printf("Starting interactive session. Type 'help' to get help.\n"); 545 printf("Starting interactive session. Type 'help' to get help.\n");
546 while(1) 546
547 if(!do_command()) 547 interactive_mode();
548 break; 548
549 Lerr: 549 Lerr:
550 if(features.feature_mask & HWEMUL_FEATURE_LOG) 550 if(features.feature_mask & HWEMUL_FEATURE_LOG)
551 { 551 {