+//-----------------------------------------------------------------------------
+// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
+#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "proxusb.h"
while (arg->run) {
if (ReceiveCommandPoll(&cmdbuf)) {
- for (int i = 0; i < strlen(PROXPROMPT); i++)
- putchar(0x08);
UsbCommandReceived(&cmdbuf);
- printf(PROXPROMPT);
fflush(NULL);
}
}
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) {
+ break;
+ }
+
+ CommandReceived(cmd);
+ add_history(cmd);
+ }
+ free(cmd);
+ } else {
+ printf("\n");
+ break;
+ }
+ }
+
+ write_history(".history");
if (arg->usb_present == 1) {
rarg.run = 0;