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