From 9d2631854c2131ad0f79962500771f5e085d66b1 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 29 Jan 2013 23:58:45 +0000 Subject: imxtools/hwemul: add readline support Change-Id: If2e86bf8b520a8d4c38a56ac969918fdeb2c6f91 --- utils/imxtools/hwemul/tools/Makefile | 2 +- utils/imxtools/hwemul/tools/hwemul_tool | Bin 1354604 -> 0 bytes utils/imxtools/hwemul/tools/hwemul_tool.c | 36 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 19 deletions(-) delete mode 100755 utils/imxtools/hwemul/tools/hwemul_tool (limited to 'utils/imxtools') diff --git a/utils/imxtools/hwemul/tools/Makefile b/utils/imxtools/hwemul/tools/Makefile index 80a2f405bb..39f0c61c2a 100644 --- a/utils/imxtools/hwemul/tools/Makefile +++ b/utils/imxtools/hwemul/tools/Makefile @@ -2,7 +2,7 @@ CC=gcc AR=ar HWEMUL_LIB_DIR=../lib CFLAGS=-W -Wall -O2 `pkg-config --cflags libusb-1.0` -std=c99 -g -I$(HWEMUL_LIB_DIR) -LDFLAGS=`pkg-config --libs libusb-1.0` +LDFLAGS=`pkg-config --libs libusb-1.0` -lreadline EXEC=hwemul_tool HWEMUL_LIB=$(HWEMUL_LIB_DIR)/libhwemul.a SRC=$(wildcard *.c) diff --git a/utils/imxtools/hwemul/tools/hwemul_tool b/utils/imxtools/hwemul/tools/hwemul_tool deleted file mode 100755 index 1690385c6a..0000000000 Binary files a/utils/imxtools/hwemul/tools/hwemul_tool and /dev/null differ 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 #include #include +#include +#include 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) { -- cgit v1.2.3