]> cvs.zerfleddert.de Git - proxmark3-svn/blob - linux/cli.c
fix crash in client when no buffer is loaded
[proxmark3-svn] / linux / cli.c
1 #include <usb.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <stdlib.h>
5 #include <strings.h>
6 #include <string.h>
7 #include <errno.h>
8
9 #include "translate.h"
10 #include "../winsrc/prox.h"
11 #include "proxmark3.h"
12
13 #define HANDLE_ERROR if (error_occured) { \
14 error_occured = 0;\
15 break;\
16 }
17
18 int main(int argc, char **argv)
19 {
20 if(argc != 3 && argc != 4)
21 {
22 printf("\n\tusage: cli <command 1> <command 2> [logfile (default cli.log)]\n");
23 printf("\n");
24 printf("\texample: cli hi14asnoop hi14alist h14a.log\n");
25 printf("\n");
26 return -1;
27 }
28
29 usb_init();
30 if (argc == 4)
31 setlogfilename(argv[3]);
32 else
33 setlogfilename("cli.log");
34
35 return_on_error = 1;
36
37 while(1) {
38 while(!(devh=OpenProxmark(0))) { sleep(1); }
39
40 while(1) {
41 UsbCommand cmdbuf;
42 int i;
43
44 CommandReceived(argv[1]);
45 HANDLE_ERROR
46
47 ReceiveCommand(&cmdbuf);
48 HANDLE_ERROR
49 for (i=0; i<5; i++) {
50 ReceiveCommandP(&cmdbuf);
51 }
52 HANDLE_ERROR
53
54 CommandReceived(argv[2]);
55 HANDLE_ERROR
56 }
57 }
58
59 CloseProxmark();
60 return 0;
61 }
Impressum, Datenschutz