]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: @piwi's fixes to .history
authoriceman1001 <iceman@iuse.se>
Mon, 9 Nov 2015 20:46:57 +0000 (21:46 +0100)
committericeman1001 <iceman@iuse.se>
Mon, 9 Nov 2015 20:46:57 +0000 (21:46 +0100)
client/cmdmain.c
client/cmdmain.h
client/cmdparser.c
client/cmdparser.h
client/proxmark3.c

index d31147f91531d7a4c633a6d6e4e77e7f570b2231..51aada76c2dcab07e51a29bab034bf62bb350861 100644 (file)
@@ -75,7 +75,7 @@ int CmdLS(const char *Cmd){
 int CmdQuit(const char *Cmd)
 {
   exit(0);
-  return 0;
+  return 99;
 }
 
 int CmdRev(const char *Cmd)
@@ -174,8 +174,8 @@ bool WaitForResponse(uint32_t cmd, UsbCommand* response) {
 // Entry point into our code: called whenever the user types a command and
 // then presses Enter, which the full command line that they typed.
 //-----------------------------------------------------------------------------
-void CommandReceived(char *Cmd) {
-  CmdsParse(CommandTable, Cmd);
+int CommandReceived(char *Cmd) {
+       return CmdsParse(CommandTable, Cmd);
 }
 
 //-----------------------------------------------------------------------------
index aa87052c782e76274159ab239b4ff92a8a0e89a7..9cb3e95d3633e498b61b274c547bf1dba3613b4b 100644 (file)
@@ -14,7 +14,7 @@
 #include "usb_cmd.h"
 #include "cmdparser.h"
 void UsbCommandReceived(UsbCommand *UC);
-void CommandReceived(char *Cmd);
+int CommandReceived(char *Cmd);
 bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout);
 bool WaitForResponse(uint32_t cmd, UsbCommand* response);
 void clearCommandBuffer();
index ae67466aab557bff38020b57712f0b836d96868a..e67bdfe54fdaedf28b5cb15d32ff2e08a91b0b21 100644 (file)
@@ -40,17 +40,17 @@ void CmdsLS(const command_t Commands[])
   }
 }
 
-void CmdsParse(const command_t Commands[], const char *Cmd)
+int CmdsParse(const command_t Commands[], const char *Cmd)
 {
   if(strcmp( Cmd, "XX_internal_command_dump_XX") == 0)
   {// Help dump children
       dumpCommandsRecursive(Commands, 0);
-      return;
+               return 0;
   }
   if(strcmp( Cmd, "XX_internal_command_dump_markdown_XX") == 0)
   {// Markdown help dump children
       dumpCommandsRecursive(Commands, 1);
-      return;
+               return 0;
   }
   char cmd_name[32];
   int len = 0;
@@ -77,11 +77,13 @@ void CmdsParse(const command_t Commands[], const char *Cmd)
   if (Commands[i].Name) {
     while (Cmd[len] == ' ')
       ++len;
-    Commands[i].Parse(Cmd + len);
+       return Commands[i].Parse(Cmd + len);
   } else {
     // show help for selected hierarchy or if command not recognised
     CmdsHelp(Commands);
   }
+
+       return 0;
 }
 
 char pparent[512] = {0};
index 34db902cc9676dbc236c49fa176618100476ade1..97b8f281393b5c4538feed645a06738ff8441a27 100644 (file)
@@ -26,7 +26,7 @@ void CmdsHelp(const command_t Commands[]);
 // Print each command in the command array without help
 void CmdsLS(const command_t Commands[]);
 // Parse a command line
-void CmdsParse(const command_t Commands[], const char *Cmd);
+int CmdsParse(const command_t Commands[], const char *Cmd);
 void dumpCommandsRecursive(const command_t cmds[], int markdown);
 
 #endif
index 5e5bba8062150e05dd5d43b31e3e5441003c0caf..641690a7fe36d5ce308480c3295c24f00a9efc65 100644 (file)
@@ -155,12 +155,11 @@ static void *main_loop(void *targ) {
         cmd[strlen(cmd) - 1] = 0x00;
                        
                        if (cmd[0] != 0x00) {
-                               if (strncmp(cmd, "quit", 4) == 0) {
-                                       exit(0);
+                               int ret = CommandReceived(cmd);
+                               add_history(cmd);
+                               if (ret == 99) {  // exit or quit
                                        break;
                                }
-                               CommandReceived(cmd);
-                               add_history(cmd);
                        }
                        free(cmd);
                } else {
@@ -223,7 +222,7 @@ int main(int argc, char* argv[]) {
                .usb_present = 0,
                .script_cmds_file = NULL
        };
-       pthread_t main_loop_t;
+       pthread_t main_loop_threat;
 
   
        sp = uart_open(argv[1]);
@@ -258,18 +257,20 @@ int main(int argc, char* argv[]) {
        // create a mutex to avoid interlacing print commands from our different threads
        pthread_mutex_init(&print_lock, NULL);
 
-       pthread_create(&main_loop_t, NULL, &main_loop, &marg);
+       pthread_create(&main_loop_threat, NULL, &main_loop, &marg);
        InitGraphics(argc, argv);
 
        MainGraphics();
 
-       pthread_join(main_loop_t, NULL);
+       pthread_join(main_loop_threat, NULL);
 
        // Clean up the port
+       if (offline == 0) {
        uart_close(sp);
+       }
   
        // clean up mutex
        pthread_mutex_destroy(&print_lock);
   
-  return 0;
+       exit(0);
 }
Impressum, Datenschutz