summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-04-26 15:09:53 +0200
committerGravatar Martin Szulecki2011-04-26 15:09:53 +0200
commite9b5eba30b3272361d846bc78b3bac6e9a8e2b40 (patch)
tree5f7e13a5a8b8511d9faa23db06dac09b82284b13
parentd2a15c5f6f0bd9cfbd4fbfe3d5139f5ac6e85d94 (diff)
downloadlibimobiledevice-e9b5eba30b3272361d846bc78b3bac6e9a8e2b40.tar.gz
libimobiledevice-e9b5eba30b3272361d846bc78b3bac6e9a8e2b40.tar.bz2
idevicebackup: Detect last file data hunk flag to prevent printing errors
We have interpreted code 0x0b as CODE_ERROR_REMOTE and printed this error to the user which was disturbing. However, it is not an error but a flag which signals the end of a series of data hunks being sent.
-rw-r--r--tools/idevicebackup4.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/idevicebackup4.c b/tools/idevicebackup4.c
index 4235e08..d7adfc1 100644
--- a/tools/idevicebackup4.c
+++ b/tools/idevicebackup4.c
@@ -697,6 +697,7 @@ static int mb2_handle_receive_files(plist_t message, const char *backup_dir)
char *fname = NULL;
gchar *bname = NULL;
char code = 0;
+ char last_code = 0;
plist_t node = NULL;
FILE *f = NULL;
unsigned int file_count = 0;
@@ -762,6 +763,7 @@ static int mb2_handle_receive_files(plist_t message, const char *backup_dir)
break;
}
nlen = GUINT32_FROM_BE(nlen);
+ last_code = code;
code = 0;
mobilebackup2_receive_raw(mobilebackup2, &code, 1, &r);
if (r != 1) {
@@ -805,6 +807,7 @@ static int mb2_handle_receive_files(plist_t message, const char *backup_dir)
mobilebackup2_receive_raw(mobilebackup2, (char*)&nlen, 4, &r);
nlen = GUINT32_FROM_BE(nlen);
if (nlen > 0) {
+ last_code = code;
mobilebackup2_receive_raw(mobilebackup2, &code, 1, &r);
} else {
break;
@@ -828,7 +831,10 @@ static int mb2_handle_receive_files(plist_t message, const char *backup_dir)
char *msg = (char*)malloc(nlen);
mobilebackup2_receive_raw(mobilebackup2, msg, nlen-1, &r);
msg[r] = 0;
- fprintf(stdout, "\nReceived an error message from device: %s\n", msg);
+ /* If sent using CODE_FILE_DATA, end marker will be CODE_ERROR_REMOTE which is not an error! */
+ if (last_code != CODE_FILE_DATA) {
+ fprintf(stdout, "\nReceived an error message from device: %s\n", msg);
+ }
free(msg);
}
} while (1);