]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/proxmark3.c
9105ca62b8acc7ce1f808de59477a291537b1550
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
3 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
8 //-----------------------------------------------------------------------------
10 //-----------------------------------------------------------------------------
17 #include <readline/readline.h>
18 #include <readline/history.h>
20 #include "proxmark3.h"
24 struct usb_receiver_arg
34 static void *usb_receiver(void *targ
)
36 struct usb_receiver_arg
*arg
= (struct usb_receiver_arg
*)targ
;
40 if (ReceiveCommandPoll(&cmdbuf
)) {
41 UsbCommandReceived(&cmdbuf
);
50 static void *main_loop(void *targ
)
52 struct main_loop_arg
*arg
= (struct main_loop_arg
*)targ
;
53 struct usb_receiver_arg rarg
;
55 pthread_t reader_thread
;
57 if (arg
->usb_present
== 1) {
59 pthread_create(&reader_thread
, NULL
, &usb_receiver
, &rarg
);
62 read_history(".history");
64 cmd
= readline(PROXPROMPT
);
66 while(cmd
[strlen(cmd
) - 1] == ' ')
67 cmd
[strlen(cmd
) - 1] = 0x00;
70 if (strncmp(cmd
, "quit", 4) == 0) {
84 write_history(".history");
86 if (arg
->usb_present
== 1) {
88 pthread_join(reader_thread
, NULL
);
96 int main(int argc
, char **argv
)
98 struct main_loop_arg marg
;
99 pthread_t main_loop_t
;
102 if (!OpenProxmark(1)) {
103 fprintf(stderr
,"PROXMARK3: NOT FOUND!\n");
104 marg
.usb_present
= 0;
107 marg
.usb_present
= 1;
111 pthread_create(&main_loop_t
, NULL
, &main_loop
, &marg
);
112 InitGraphics(argc
, argv
);
116 pthread_join(main_loop_t
, NULL
);
118 if (marg
.usb_present
== 1) {