diff options
author | Jefferson Delfes <jefferson.delfes@gmail.com> | 2013-10-19 13:25:47 -0400 |
---|---|---|
committer | Jefferson Delfes <jefferson.delfes@gmail.com> | 2013-10-21 14:30:07 -0400 |
commit | 5254dee1e0169f584939eaa0e94c0b878f2d00e2 (patch) | |
tree | 836e4667c54e4c1da47e491d0fdccb188877ae75 | |
parent | 175f4a98033e54e77dc85f7a9658f00f492c775b (diff) |
Initialize rl_helper and feed it
-rw-r--r-- | btctl.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -32,6 +32,7 @@ #include <hardware/hardware.h> #include "util.h" +#include "rl_helper.h" #define MAX_LINE_SIZE 64 @@ -953,7 +954,7 @@ static void bt_init() { } int main (int argc, char * argv[]) { - char line[MAX_LINE_SIZE]; + rl_init(cmd_process); printf("Android Bluetooth control tool version 0.1\n"); @@ -961,12 +962,9 @@ int main (int argc, char * argv[]) { cmd_prompt(); - while (!u.quit && fgets(line, MAX_LINE_SIZE, stdin)) { - /* remove linefeed */ - line[strlen(line)-1] = 0; - - cmd_process(line); - + while (!u.quit) { + int c = getchar(); + rl_feed(c); if (!u.quit) cmd_prompt(); } @@ -981,6 +979,6 @@ int main (int argc, char * argv[]) { while (u.btiface_initialized) usleep(10000); - printf("\n"); + rl_quit(); return 0; } |