- struct main_loop_arg *arg = (struct main_loop_arg*)targ;
- char *cmd = NULL;
-
- while(1) {
- struct usb_receiver_arg rarg;
- pthread_t reader_thread;
-
- rarg.run=1;
- if (arg->usb_present == 1) {
- pthread_create(&reader_thread, NULL, &usb_receiver, &rarg);
- }
- cmd = readline(PROXPROMPT);
- rarg.run=0;
- if (arg->usb_present == 1) {
- pthread_join(reader_thread, NULL);
- }
-
- if (cmd) {
- if (cmd[0] != 0x00) {
- CommandReceived(cmd);
- add_history(cmd);
- }
- free(cmd);
- } else {
- printf("\n");
- break;
- }
- }
-
- ExitGraphics();
- pthread_exit(NULL);
+ struct main_loop_arg *arg = (struct main_loop_arg*)targ;
+ struct usb_receiver_arg rarg;
+ char *cmd = NULL;
+ pthread_t reader_thread;
+
+ if (arg->usb_present == 1) {
+ rarg.run=1;
+ pthread_create(&reader_thread, NULL, &usb_receiver, &rarg);
+ }
+
+ while(1) {
+ cmd = readline(PROXPROMPT);
+ if (cmd) {
+ while(cmd[strlen(cmd) - 1] == ' ')
+ cmd[strlen(cmd) - 1] = 0x00;
+ if (cmd[0] != 0x00) {
+ CommandReceived(cmd);
+ add_history(cmd);
+ }
+ free(cmd);
+ } else {
+ printf("\n");
+ break;
+ }
+ }
+
+ if (arg->usb_present == 1) {
+ rarg.run = 0;
+ pthread_join(reader_thread, NULL);
+ }
+
+ ExitGraphics();
+ pthread_exit(NULL);
+ return NULL;