X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/7fe9b0b742d7dae9c5af1d292d11840b5c3cbfae..8556b852ed769280d1b63054ab1bd08fa19b746a:/client/proxmark3.c diff --git a/client/proxmark3.c b/client/proxmark3.c index 830a1245..fe3ba7c5 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -1,6 +1,19 @@ +//----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// Copyright (C) 2010 iZsh +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// Main binary +//----------------------------------------------------------------------------- + #include +#include #include #include +#include #include #include #include "proxusb.h" @@ -28,12 +41,17 @@ static void *usb_receiver(void *targ) for (int i = 0; i < strlen(PROXPROMPT); i++) putchar(0x08); UsbCommandReceived(&cmdbuf); - printf(PROXPROMPT); + // there is a big bug ) + if (cmdbuf.cmd > 0x0100 && cmdbuf.cmd < 0x0110) { // debug commands + rl_on_new_line_with_prompt(); + rl_forced_update_display(); + } fflush(NULL); } } pthread_exit(NULL); + return NULL; } static void *main_loop(void *targ) @@ -48,19 +66,28 @@ static void *main_loop(void *targ) pthread_create(&reader_thread, NULL, &usb_receiver, &rarg); } - while(1) { - cmd = readline(PROXPROMPT); - if (cmd) { - if (cmd[0] != 0x00) { - CommandReceived(cmd); - add_history(cmd); - } - free(cmd); - } else { - printf("\n"); - break; - } - } + read_history(".history"); + while(1) { + cmd = readline(PROXPROMPT); + if (cmd) { + while(cmd[strlen(cmd) - 1] == ' ') + cmd[strlen(cmd) - 1] = 0x00; + + if (cmd[0] != 0x00) { + if (strncmp(cmd, "quit", 4) == 0) { + write_history(".history"); + break; + } + + CommandReceived(cmd); + add_history(cmd); + } + free(cmd); + } else { + printf("\n"); + break; + } + } if (arg->usb_present == 1) { rarg.run = 0; @@ -69,6 +96,7 @@ static void *main_loop(void *targ) ExitGraphics(); pthread_exit(NULL); + return NULL; } int main(int argc, char **argv)