mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
CHG: Syntax suger
This commit is contained in:
parent
d798d31cbe
commit
87b28d31a1
1 changed files with 96 additions and 90 deletions
|
@ -48,6 +48,7 @@ void SendCommand(UsbCommand *c) {
|
|||
Not good.../holiman
|
||||
**/
|
||||
while(txcmd_pending);
|
||||
|
||||
txcmd = *c;
|
||||
txcmd_pending = true;
|
||||
}
|
||||
|
@ -70,17 +71,19 @@ static void *uart_receiver(void *targ) {
|
|||
size_t cmd_count;
|
||||
|
||||
while (arg->run) {
|
||||
|
||||
rxlen = sizeof(UsbCommand);
|
||||
|
||||
if (uart_receive(sp, prx, &rxlen)) {
|
||||
prx += rxlen;
|
||||
if (((prx-rx) % sizeof(UsbCommand)) != 0) {
|
||||
if (((prx-rx) % sizeof(UsbCommand)) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
cmd_count = (prx-rx) / sizeof(UsbCommand);
|
||||
|
||||
for (size_t i = 0; i < cmd_count; i++) {
|
||||
for (size_t i = 0; i < cmd_count; i++)
|
||||
UsbCommandReceived((UsbCommand*)( rx + ( i * sizeof(UsbCommand))));
|
||||
}
|
||||
|
||||
}
|
||||
prx = rx;
|
||||
|
||||
|
@ -110,13 +113,13 @@ static void *main_loop(void *targ) {
|
|||
}
|
||||
|
||||
FILE *script_file = NULL;
|
||||
char script_cmd_buf[256]; // iceman, needs lua script the same file_path_buffer as the rest
|
||||
char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
|
||||
|
||||
if (arg->script_cmds_file) {
|
||||
script_file = fopen(arg->script_cmds_file, "r");
|
||||
if (script_file) {
|
||||
|
||||
if (script_file)
|
||||
printf("using 'scripting' commands file %s\n", arg->script_cmds_file);
|
||||
}
|
||||
}
|
||||
|
||||
read_history(".history");
|
||||
|
@ -132,10 +135,13 @@ static void *main_loop(void *targ) {
|
|||
} else {
|
||||
char *nl;
|
||||
nl = strrchr(script_cmd_buf, '\r');
|
||||
if (nl) *nl = '\0';
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
|
||||
nl = strrchr(script_cmd_buf, '\n');
|
||||
if (nl) *nl = '\0';
|
||||
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
|
||||
if ((cmd = (char*) malloc(strlen(script_cmd_buf) + 1)) != NULL) {
|
||||
memset(cmd, 0, strlen(script_cmd_buf));
|
||||
|
@ -143,9 +149,7 @@ static void *main_loop(void *targ) {
|
|||
printf("%s\n", cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!script_file) {
|
||||
} else {
|
||||
cmd = readline(PROXPROMPT);
|
||||
}
|
||||
|
||||
|
@ -157,10 +161,11 @@ static void *main_loop(void *targ) {
|
|||
if (cmd[0] != 0x00) {
|
||||
int ret = CommandReceived(cmd);
|
||||
add_history(cmd);
|
||||
if (ret == 99) { // exit or quit
|
||||
|
||||
// exit or quit
|
||||
if (ret == 99)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(cmd);
|
||||
} else {
|
||||
printf("\n");
|
||||
|
@ -222,6 +227,7 @@ int main(int argc, char* argv[]) {
|
|||
.usb_present = 0,
|
||||
.script_cmds_file = NULL
|
||||
};
|
||||
|
||||
pthread_t main_loop_threat;
|
||||
|
||||
|
||||
|
@ -250,9 +256,10 @@ int main(int argc, char* argv[]) {
|
|||
printf("Output will be flushed after every print.\n");
|
||||
flushAfterWrite = 1;
|
||||
}
|
||||
else
|
||||
else {
|
||||
marg.script_cmds_file = argv[2];
|
||||
}
|
||||
}
|
||||
|
||||
// create a mutex to avoid interlacing print commands from our different threads
|
||||
pthread_mutex_init(&print_lock, NULL);
|
||||
|
@ -265,9 +272,8 @@ int main(int argc, char* argv[]) {
|
|||
pthread_join(main_loop_threat, NULL);
|
||||
|
||||
// Clean up the port
|
||||
if (offline == 0) {
|
||||
if (offline == 0)
|
||||
uart_close(sp);
|
||||
}
|
||||
|
||||
// clean up mutex
|
||||
pthread_mutex_destroy(&print_lock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue