summaryrefslogtreecommitdiffstats
path: root/src/AFC.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/AFC.c')
-rw-r--r--src/AFC.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 44dcee5..d2bae97 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -159,7 +159,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
159 return -1; 159 return -1;
160 } 160 }
161 memcpy(buffer+sizeof(AFCPacket), data, offset); 161 memcpy(buffer+sizeof(AFCPacket), data, offset);
162 bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length); 162 iphone_mux_send(client->connection, buffer, client->afc_packet->this_length, &bytes);
163 free(buffer); 163 free(buffer);
164 if (bytes <= 0) { 164 if (bytes <= 0) {
165 return bytes; 165 return bytes;
@@ -172,7 +172,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
172 fwrite(data+offset, 1, length-offset, stdout); 172 fwrite(data+offset, 1, length-offset, stdout);
173 } 173 }
174 174
175 bytes = iphone_mux_send(client->connection, data+offset, length-offset); 175 iphone_mux_send(client->connection, data+offset, length-offset, &bytes);
176 return bytes; 176 return bytes;
177 } else { 177 } else {
178 if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n"); 178 if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n");
@@ -183,7 +183,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
183 if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; } 183 if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; }
184 if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout); 184 if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout);
185 if (debug) fprintf(stderr, "\n"); 185 if (debug) fprintf(stderr, "\n");
186 bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length); 186 iphone_mux_send(client->connection, buffer, client->afc_packet->this_length, &bytes);
187 187
188 if (buffer) { 188 if (buffer) {
189 free(buffer); 189 free(buffer);
@@ -212,7 +212,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
212 int bytes = 0, recv_len = 0, current_count=0; 212 int bytes = 0, recv_len = 0, current_count=0;
213 int retval = 0; 213 int retval = 0;
214 214
215 bytes = iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4); 215 iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4, &bytes);
216 if (bytes <= 0) { 216 if (bytes <= 0) {
217 free(buffer); 217 free(buffer);
218 fprintf(stderr, "Just didn't get enough.\n"); 218 fprintf(stderr, "Just didn't get enough.\n");
@@ -265,7 +265,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
265 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE); 265 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);
266 final_buffer = (char*)malloc(sizeof(char) * recv_len); 266 final_buffer = (char*)malloc(sizeof(char) * recv_len);
267 while(current_count < recv_len){ 267 while(current_count < recv_len){
268 bytes = iphone_mux_recv(client->connection, buffer, recv_len-current_count); 268 iphone_mux_recv(client->connection, buffer, recv_len-current_count, &bytes);
269 if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n"); 269 if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n");
270 if (bytes < 0) 270 if (bytes < 0)
271 { 271 {
@@ -331,7 +331,7 @@ iphone_error_t iphone_afc_get_dir_list ( iphone_afc_client_t client, const char
331 char *data = NULL, **list_loc = NULL; 331 char *data = NULL, **list_loc = NULL;
332 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; 332 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
333 333
334 if (!client || !dir || !list) return IPHONE_E_INVALID_ARG; 334 if (!client || !dir || !list || (list && *list)) return IPHONE_E_INVALID_ARG;
335 335
336 afc_lock(client); 336 afc_lock(client);
337 337
@@ -714,11 +714,11 @@ iphone_error_t iphone_afc_read_file ( iphone_afc_client_t client, iphone_afc_fil
714 // Receive the data 714 // Receive the data
715 bytes_loc = receive_AFC_data(client, &input); 715 bytes_loc = receive_AFC_data(client, &input);
716 if (debug) fprintf(stderr, "afc_read_file: bytes returned: %i\n", bytes_loc); 716 if (debug) fprintf(stderr, "afc_read_file: bytes returned: %i\n", bytes_loc);
717 if (bytes < 0) { 717 if (bytes_loc < 0) {
718 if (input) free(input); 718 if (input) free(input);
719 afc_unlock(client); 719 afc_unlock(client);
720 return IPHONE_E_NOT_ENOUGH_DATA; 720 return IPHONE_E_NOT_ENOUGH_DATA;
721 } else if (bytes == 0) { 721 } else if (bytes_loc == 0) {
722 if (input) free(input); 722 if (input) free(input);
723 afc_unlock(client); 723 afc_unlock(client);
724 *bytes = current_count; 724 *bytes = current_count;
@@ -756,7 +756,7 @@ iphone_error_t iphone_afc_write_file ( iphone_afc_client_t client, iphone_afc_fi
756 uint32 zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0; 756 uint32 zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0;
757 char *out_buffer = NULL; 757 char *out_buffer = NULL;
758 758
759 if (!client ||!client->afc_packet || !client->connection || !file || !bytes_loc) return IPHONE_E_INVALID_ARG; 759 if (!client ||!client->afc_packet || !client->connection || !file || !bytes) return IPHONE_E_INVALID_ARG;
760 760
761 afc_lock(client); 761 afc_lock(client);
762 762
@@ -821,8 +821,8 @@ iphone_error_t iphone_afc_write_file ( iphone_afc_client_t client, iphone_afc_fi
821 if (bytes_loc < 0) { 821 if (bytes_loc < 0) {
822 if (debug) fprintf(stderr, "afc_write_file: uh oh?\n"); 822 if (debug) fprintf(stderr, "afc_write_file: uh oh?\n");
823 } 823 }
824 824 *bytes = current_count;
825 return IPHONE_E_UNKNOWN_ERROR; 825 return IPHONE_E_SUCCESS;
826} 826}
827 827
828/** Closes a file on the phone. 828/** Closes a file on the phone.