summaryrefslogtreecommitdiffstats
path: root/src/irecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-05-16 14:15:26 -0400
committerGravatar Joshua Hill2010-05-16 14:15:26 -0400
commit3491ef9c41f1cd867028881a8beebf1ad55373c7 (patch)
treea8a0621e59f897544b1218eaf0ca513e1775a5cb /src/irecovery.c
parente7cc5716d941ee2c1ec554926e76448092d9e0c5 (diff)
downloadlibirecovery-3491ef9c41f1cd867028881a8beebf1ad55373c7.tar.gz
libirecovery-3491ef9c41f1cd867028881a8beebf1ad55373c7.tar.bz2
Added irecv_set_configuration() and irecv_set_interface() functions and implemented bulk read
Diffstat (limited to 'src/irecovery.c')
-rw-r--r--src/irecovery.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/irecovery.c b/src/irecovery.c
index 2ab0aaa..8ffe86b 100644
--- a/src/irecovery.c
+++ b/src/irecovery.c
@@ -29,7 +29,8 @@ enum {
29 kResetDevice, kStartShell, kSendCommand, kSendFile 29 kResetDevice, kStartShell, kSendCommand, kSendFile
30}; 30};
31 31
32static unsigned int exit_shell = 0; 32static unsigned int quit = 0;
33static unsigned int debug = 0;
33 34
34void print_shell_usage() { 35void print_shell_usage() {
35 printf("Usage:\n"); 36 printf("Usage:\n");
@@ -41,7 +42,7 @@ void print_shell_usage() {
41void parse_command(irecv_device_t* device, unsigned char* command, unsigned int size) { 42void parse_command(irecv_device_t* device, unsigned char* command, unsigned int size) {
42 char* cmd = strtok(command, " "); 43 char* cmd = strtok(command, " ");
43 if(!strcmp(command, "/exit")) { 44 if(!strcmp(command, "/exit")) {
44 exit_shell = 1; 45 quit = 1;
45 } else 46 } else
46 47
47 if(!strcmp(command, "/help")) { 48 if(!strcmp(command, "/help")) {
@@ -56,7 +57,7 @@ void parse_command(irecv_device_t* device, unsigned char* command, unsigned int
56 } 57 }
57} 58}
58 59
59int recv_callback(irecv_device_t* device, unsigned char* data, unsigned int size) { 60int recv_callback(irecv_device_t* device, unsigned char* data, int size) {
60 int i = 0; 61 int i = 0;
61 for(i = 0; i < size; i++) { 62 for(i = 0; i < size; i++) {
62 printf("%c", data[i]); 63 printf("%c", data[i]);
@@ -64,7 +65,7 @@ int recv_callback(irecv_device_t* device, unsigned char* data, unsigned int size
64 return size; 65 return size;
65} 66}
66 67
67int send_callback(irecv_device_t* device, unsigned char* command, unsigned int size) { 68int send_callback(irecv_device_t* device, unsigned char* command, int size) {
68 if(command[0] == '/') { 69 if(command[0] == '/') {
69 parse_command(device, command, size); 70 parse_command(device, command, size);
70 return 0; 71 return 0;
@@ -85,14 +86,14 @@ void init_shell(irecv_device_t* device) {
85 load_command_history(); 86 load_command_history();
86 irecv_set_sender(device, &send_callback); 87 irecv_set_sender(device, &send_callback);
87 irecv_set_receiver(device, &recv_callback); 88 irecv_set_receiver(device, &recv_callback);
88 while(!exit_shell) { 89 while(!quit) {
90 irecv_update(device);
89 char* cmd = readline("> "); 91 char* cmd = readline("> ");
90 if(cmd && *cmd) { 92 if(cmd && *cmd) {
91 irecv_send_command(device, cmd); 93 irecv_send_command(device, cmd);
92 append_command_to_history(cmd); 94 append_command_to_history(cmd);
93 free(cmd); 95 free(cmd);
94 } 96 }
95 irecv_update(device);
96 } 97 }
97} 98}
98 99
@@ -110,7 +111,6 @@ void print_usage() {
110 111
111int main(int argc, char** argv) { 112int main(int argc, char** argv) {
112 int opt = 0; 113 int opt = 0;
113 int debug = 0;
114 int action = 0; 114 int action = 0;
115 char* argument = NULL; 115 char* argument = NULL;
116 if(argc == 1) print_usage(); 116 if(argc == 1) print_usage();