summaryrefslogtreecommitdiffstats
path: root/src/irecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-05-16 15:48:19 -0400
committerGravatar Joshua Hill2010-05-16 15:48:19 -0400
commit34fc43b128e475fda4e9834689e3649eba82c4c9 (patch)
tree60ceb87bd3098ab96cb96cf359275f162ea0d90c /src/irecovery.c
parent3491ef9c41f1cd867028881a8beebf1ad55373c7 (diff)
downloadlibirecovery-34fc43b128e475fda4e9834689e3649eba82c4c9.tar.gz
libirecovery-34fc43b128e475fda4e9834689e3649eba82c4c9.tar.bz2
added irecv_errorstr() and fixed a few bugs
Diffstat (limited to 'src/irecovery.c')
-rw-r--r--src/irecovery.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/irecovery.c b/src/irecovery.c
index 8ffe86b..7133606 100644
--- a/src/irecovery.c
+++ b/src/irecovery.c
@@ -30,7 +30,7 @@ enum {
30}; 30};
31 31
32static unsigned int quit = 0; 32static unsigned int quit = 0;
33static unsigned int debug = 0; 33static unsigned int verbose = 0;
34 34
35void print_shell_usage() { 35void print_shell_usage() {
36 printf("Usage:\n"); 36 printf("Usage:\n");
@@ -50,7 +50,7 @@ void parse_command(irecv_device_t* device, unsigned char* command, unsigned int
50 } else 50 } else
51 51
52 if(!strcmp(command, "/upload")) { 52 if(!strcmp(command, "/upload")) {
53 char* filename = strtok(0, " "); 53 char* filename = strtok(NULL, " ");
54 if(filename != NULL) { 54 if(filename != NULL) {
55 irecv_send_file(device, filename); 55 irecv_send_file(device, filename);
56 } 56 }
@@ -87,10 +87,16 @@ void init_shell(irecv_device_t* device) {
87 irecv_set_sender(device, &send_callback); 87 irecv_set_sender(device, &send_callback);
88 irecv_set_receiver(device, &recv_callback); 88 irecv_set_receiver(device, &recv_callback);
89 while(!quit) { 89 while(!quit) {
90 irecv_update(device); 90 if(irecv_update(device) != IRECV_SUCCESS) {
91 break;
92 }
93
91 char* cmd = readline("> "); 94 char* cmd = readline("> ");
92 if(cmd && *cmd) { 95 if(cmd && *cmd) {
93 irecv_send_command(device, cmd); 96 if(irecv_send_command(device, cmd) != IRECV_SUCCESS) {
97 quit = 1;
98 }
99
94 append_command_to_history(cmd); 100 append_command_to_history(cmd);
95 free(cmd); 101 free(cmd);
96 } 102 }
@@ -100,8 +106,8 @@ void init_shell(irecv_device_t* device) {
100void print_usage() { 106void print_usage() {
101 printf("iRecovery - iDevice Recovery Utility\n"); 107 printf("iRecovery - iDevice Recovery Utility\n");
102 printf("Usage: ./irecovery [args]\n"); 108 printf("Usage: ./irecovery [args]\n");
109 printf("\t-v\t\tStart irecovery in verbose mode.\n");
103 printf("\t-c <cmd>\tSend command to device.\n"); 110 printf("\t-c <cmd>\tSend command to device.\n");
104 printf("\t-d\t\tStart irecovery in debug mode.\n");
105 printf("\t-f <file>\tSend file to device.\n"); 111 printf("\t-f <file>\tSend file to device.\n");
106 printf("\t-h\t\tShow this help.\n"); 112 printf("\t-h\t\tShow this help.\n");
107 printf("\t-r\t\tReset device.\n"); 113 printf("\t-r\t\tReset device.\n");
@@ -114,10 +120,10 @@ int main(int argc, char** argv) {
114 int action = 0; 120 int action = 0;
115 char* argument = NULL; 121 char* argument = NULL;
116 if(argc == 1) print_usage(); 122 if(argc == 1) print_usage();
117 while ((opt = getopt(argc, argv, "dhrsc:f:")) > 0) { 123 while ((opt = getopt(argc, argv, "vhrsc:f:")) > 0) {
118 switch (opt) { 124 switch (opt) {
119 case 'd': 125 case 'v':
120 debug = 1; 126 verbose += 1;
121 break; 127 break;
122 128
123 case 'h': 129 case 'h':
@@ -153,7 +159,7 @@ int main(int argc, char** argv) {
153 fprintf(stderr, "Unable to initialize libirecovery\n"); 159 fprintf(stderr, "Unable to initialize libirecovery\n");
154 return -1; 160 return -1;
155 } 161 }
156 if(debug) irecv_set_debug(device, 1); 162 if(verbose) irecv_set_debug(device, verbose);
157 163
158 if(irecv_open(device) < 0) { 164 if(irecv_open(device) < 0) {
159 fprintf(stderr, "Unable to open device\n"); 165 fprintf(stderr, "Unable to open device\n");