diff options
Diffstat (limited to 'src/irecovery.c')
| -rw-r--r-- | src/irecovery.c | 14 |
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 | ||
| 32 | static unsigned int exit_shell = 0; | 32 | static unsigned int quit = 0; |
| 33 | static unsigned int debug = 0; | ||
| 33 | 34 | ||
| 34 | void print_shell_usage() { | 35 | void print_shell_usage() { |
| 35 | printf("Usage:\n"); | 36 | printf("Usage:\n"); |
| @@ -41,7 +42,7 @@ void print_shell_usage() { | |||
| 41 | void parse_command(irecv_device_t* device, unsigned char* command, unsigned int size) { | 42 | void 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 | ||
| 59 | int recv_callback(irecv_device_t* device, unsigned char* data, unsigned int size) { | 60 | int 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 | ||
| 67 | int send_callback(irecv_device_t* device, unsigned char* command, unsigned int size) { | 68 | int 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 | ||
| 111 | int main(int argc, char** argv) { | 112 | int 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(); |
