summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicebackup4.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/idevicebackup4.c b/tools/idevicebackup4.c
index f306260..40f1a83 100644
--- a/tools/idevicebackup4.c
+++ b/tools/idevicebackup4.c
@@ -377,7 +377,7 @@ static int plist_write_to_filename(plist_t plist, const char *filename, enum pli
377 return 1; 377 return 1;
378} 378}
379 379
380static int mobilebackup_status_check_snapshot_state(const char *path, const char *uuid, const char *matches) 380static int mb2_status_check_snapshot_state(const char *path, const char *uuid, const char *matches)
381{ 381{
382 int ret = -1; 382 int ret = -1;
383 plist_t status_plist = NULL; 383 plist_t status_plist = NULL;
@@ -520,7 +520,7 @@ static void print_progress(uint64_t current, uint64_t total)
520 printf("\n"); 520 printf("\n");
521} 521}
522 522
523static void multi_status_add_file_error(plist_t status_dict, const char *path, int error_code, const char *error_message) 523static void mb2_multi_status_add_file_error(plist_t status_dict, const char *path, int error_code, const char *error_message)
524{ 524{
525 if (!status_dict) return; 525 if (!status_dict) return;
526 plist_t filedict = plist_new_dict(); 526 plist_t filedict = plist_new_dict();
@@ -541,7 +541,7 @@ static int errno_to_device_error(int errno_value)
541 } 541 }
542} 542}
543 543
544static int handle_send_file(const char *backup_dir, const char *path, plist_t *errplist) 544static int mb2_handle_send_file(const char *backup_dir, const char *path, plist_t *errplist)
545{ 545{
546 uint32_t nlen = 0; 546 uint32_t nlen = 0;
547 uint32_t pathlen = strlen(path); 547 uint32_t pathlen = strlen(path);
@@ -654,7 +654,7 @@ leave:
654 *errplist = plist_new_dict(); 654 *errplist = plist_new_dict();
655 } 655 }
656 char *errdesc = strerror(errcode); 656 char *errdesc = strerror(errcode);
657 multi_status_add_file_error(*errplist, path, errno_to_device_error(errcode), errdesc); 657 mb2_multi_status_add_file_error(*errplist, path, errno_to_device_error(errcode), errdesc);
658 658
659 length = strlen(errdesc); 659 length = strlen(errdesc);
660 nlen = GUINT32_TO_BE(length+1); 660 nlen = GUINT32_TO_BE(length+1);
@@ -679,7 +679,7 @@ leave_proto_err:
679 return result; 679 return result;
680} 680}
681 681
682static void handle_send_files(plist_t message, const char *backup_dir) 682static void mb2_handle_send_files(plist_t message, const char *backup_dir)
683{ 683{
684 uint32_t cnt; 684 uint32_t cnt;
685 uint32_t i = 0; 685 uint32_t i = 0;
@@ -702,7 +702,7 @@ static void handle_send_files(plist_t message, const char *backup_dir)
702 if (!str) 702 if (!str)
703 continue; 703 continue;
704 704
705 if (handle_send_file(backup_dir, str, &errplist) < 0) { 705 if (mb2_handle_send_file(backup_dir, str, &errplist) < 0) {
706 //printf("Error when sending file '%s' to device\n", str); 706 //printf("Error when sending file '%s' to device\n", str);
707 // TODO: perhaps we can continue, we've got a multi status response?! 707 // TODO: perhaps we can continue, we've got a multi status response?!
708 break; 708 break;
@@ -721,7 +721,7 @@ static void handle_send_files(plist_t message, const char *backup_dir)
721 } 721 }
722} 722}
723 723
724static int handle_receive_files(plist_t message, const char *backup_dir) 724static int mb2_handle_receive_files(plist_t message, const char *backup_dir)
725{ 725{
726 uint64_t backup_real_size = 0; 726 uint64_t backup_real_size = 0;
727 uint64_t backup_total_size = 0; 727 uint64_t backup_total_size = 0;
@@ -858,7 +858,7 @@ static int handle_receive_files(plist_t message, const char *backup_dir)
858 return file_count; 858 return file_count;
859} 859}
860 860
861static void handle_list_directory(plist_t message, const char *backup_dir) 861static void mb2_handle_list_directory(plist_t message, const char *backup_dir)
862{ 862{
863 if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 2 || !backup_dir) return; 863 if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 2 || !backup_dir) return;
864 864
@@ -913,7 +913,7 @@ static void handle_list_directory(plist_t message, const char *backup_dir)
913 } 913 }
914} 914}
915 915
916static void handle_make_directory(plist_t message, const char *backup_dir) 916static void mb2_handle_make_directory(plist_t message, const char *backup_dir)
917{ 917{
918 if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 2 || !backup_dir) return; 918 if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 2 || !backup_dir) return;
919 919
@@ -1248,7 +1248,7 @@ checkpoint:
1248 /* TODO: verify battery on AC enough battery remaining */ 1248 /* TODO: verify battery on AC enough battery remaining */
1249 1249
1250 /* verify if Status.plist says we read from an successful backup */ 1250 /* verify if Status.plist says we read from an successful backup */
1251 if (!mobilebackup_status_check_snapshot_state(backup_directory, uuid, "finished")) { 1251 if (!mb2_status_check_snapshot_state(backup_directory, uuid, "finished")) {
1252 printf("ERROR: Cannot ensure we restore from a successful backup. Aborting.\n"); 1252 printf("ERROR: Cannot ensure we restore from a successful backup. Aborting.\n");
1253 cmd = CMD_LEAVE; 1253 cmd = CMD_LEAVE;
1254 break; 1254 break;
@@ -1322,16 +1322,16 @@ checkpoint:
1322 1322
1323 if (!strcmp(dlmsg, "DLMessageDownloadFiles")) { 1323 if (!strcmp(dlmsg, "DLMessageDownloadFiles")) {
1324 /* device wants to download files from the computer */ 1324 /* device wants to download files from the computer */
1325 handle_send_files(message, backup_directory); 1325 mb2_handle_send_files(message, backup_directory);
1326 } else if (!strcmp(dlmsg, "DLMessageUploadFiles")) { 1326 } else if (!strcmp(dlmsg, "DLMessageUploadFiles")) {
1327 /* device wants to send files to the computer */ 1327 /* device wants to send files to the computer */
1328 file_count += handle_receive_files(message, backup_directory); 1328 file_count += mb2_handle_receive_files(message, backup_directory);
1329 } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) { 1329 } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) {
1330 /* list directory contents */ 1330 /* list directory contents */
1331 handle_list_directory(message, backup_directory); 1331 mb2_handle_list_directory(message, backup_directory);
1332 } else if (!strcmp(dlmsg, "DLMessageCreateDirectory")) { 1332 } else if (!strcmp(dlmsg, "DLMessageCreateDirectory")) {
1333 /* make a directory */ 1333 /* make a directory */
1334 handle_make_directory(message, backup_directory); 1334 mb2_handle_make_directory(message, backup_directory);
1335 } else if (!strcmp(dlmsg, "DLMessageMoveFiles")) { 1335 } else if (!strcmp(dlmsg, "DLMessageMoveFiles")) {
1336 /* perform a series of rename operations */ 1336 /* perform a series of rename operations */
1337 plist_t moves = plist_array_get_item(message, 1); 1337 plist_t moves = plist_array_get_item(message, 1);
@@ -1500,7 +1500,7 @@ files_out:
1500 1500
1501 if (cmd == CMD_BACKUP) { 1501 if (cmd == CMD_BACKUP) {
1502 printf("Received %d files from device.\n", file_count); 1502 printf("Received %d files from device.\n", file_count);
1503 if (mobilebackup_status_check_snapshot_state(backup_directory, uuid, "finished")) { 1503 if (mb2_status_check_snapshot_state(backup_directory, uuid, "finished")) {
1504 printf("Backup Successful.\n"); 1504 printf("Backup Successful.\n");
1505 } else { 1505 } else {
1506 if (quit_flag) 1506 if (quit_flag)