imxtools/hwemul: add readline support
Change-Id: If2e86bf8b520a8d4c38a56ac969918fdeb2c6f91
This commit is contained in:
parent
6d5b1b2448
commit
9d2631854c
3 changed files with 19 additions and 19 deletions
|
@ -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)
|
||||
|
|
Binary file not shown.
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue