]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/proxmark3.c
209e132c6f683e08d9291f4a6051e32ef74b24b8
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 for (int i
= 0; i
< strlen(PROXPROMPT
); i
++)
43 UsbCommandReceived(&cmdbuf
);
44 // there is a big bug )
45 if (cmdbuf
.cmd
>= 0x0100 && cmdbuf
.cmd
<= 0x0110) { // debug commands
47 // rl_on_new_line_with_prompt();
48 // rl_forced_update_display();
58 static void *main_loop(void *targ
)
60 struct main_loop_arg
*arg
= (struct main_loop_arg
*)targ
;
61 struct usb_receiver_arg rarg
;
63 pthread_t reader_thread
;
65 if (arg
->usb_present
== 1) {
67 pthread_create(&reader_thread
, NULL
, &usb_receiver
, &rarg
);
70 read_history(".history");
72 cmd
= readline(PROXPROMPT
);
74 while(cmd
[strlen(cmd
) - 1] == ' ')
75 cmd
[strlen(cmd
) - 1] = 0x00;
78 if (strncmp(cmd
, "quit", 4) == 0) {
79 write_history(".history");
93 if (arg
->usb_present
== 1) {
95 pthread_join(reader_thread
, NULL
);
103 int main(int argc
, char **argv
)
105 struct main_loop_arg marg
;
106 pthread_t main_loop_t
;
109 if (!OpenProxmark(1)) {
110 fprintf(stderr
,"PROXMARK3: NOT FOUND!\n");
111 marg
.usb_present
= 0;
114 marg
.usb_present
= 1;
118 pthread_create(&main_loop_t
, NULL
, &main_loop
, &marg
);
119 InitGraphics(argc
, argv
);
123 pthread_join(main_loop_t
, NULL
);
125 if (marg
.usb_present
== 1) {