diff options
Diffstat (limited to 'tools/idevicebackup2.c')
| -rw-r--r-- | tools/idevicebackup2.c | 93 | 
1 files changed, 1 insertions, 92 deletions
| diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 35d3ccb..2da4971 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -36,6 +36,7 @@  #include <libimobiledevice/mobilebackup2.h>  #include <libimobiledevice/notification_proxy.h>  #include <libimobiledevice/afc.h> +#include "common/utils.h"  #include <endianness.h> @@ -73,11 +74,6 @@ enum cmd_mode {  	CMD_CLOUD  }; -enum plist_format_t { -	PLIST_FORMAT_XML, -	PLIST_FORMAT_BINARY -}; -  enum cmd_flags {  	CMD_FLAG_RESTORE_SYSTEM_FILES       = (1 << 1),  	CMD_FLAG_RESTORE_REBOOT             = (1 << 2), @@ -357,93 +353,6 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, lockdownd_c  	return ret;  } -static void buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length) -{ -	FILE *f; -	uint64_t size; - -	*length = 0; - -	f = fopen(filename, "rb"); -	if (!f) { -		return; -	} - -	fseek(f, 0, SEEK_END); -	size = ftell(f); -	rewind(f); - -	if (size == 0) { -		return; -	} - -	*buffer = (char*)malloc(sizeof(char)*size); -	fread(*buffer, sizeof(char), size, f); -	fclose(f); - -	*length = size; -} - -static void buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length) -{ -	FILE *f; - -	f = fopen(filename, "ab"); -	if (!f) -		f = fopen(filename, "wb"); -	if (f) { -		fwrite(buffer, sizeof(char), length, f); -		fclose(f); -	} -} - -static int plist_read_from_filename(plist_t *plist, const char *filename) -{ -	char *buffer = NULL; -	uint64_t length; - -	if (!filename) -		return 0; - -	buffer_read_from_filename(filename, &buffer, &length); - -	if (!buffer) { -		return 0; -	} - -	if ((length > 8) && (memcmp(buffer, "bplist00", 8) == 0)) { -		plist_from_bin(buffer, length, plist); -	} else { -		plist_from_xml(buffer, length, plist); -	} - -	free(buffer); - -	return 1; -} - -static int plist_write_to_filename(plist_t plist, const char *filename, enum plist_format_t format) -{ -	char *buffer = NULL; -	uint32_t length; - -	if (!plist || !filename) -		return 0; - -	if (format == PLIST_FORMAT_XML) -		plist_to_xml(plist, &buffer, &length); -	else if (format == PLIST_FORMAT_BINARY) -		plist_to_bin(plist, &buffer, &length); -	else -		return 0; - -	buffer_write_to_filename(filename, buffer, length); - -	free(buffer); - -	return 1; -} -  static int mb2_status_check_snapshot_state(const char *path, const char *udid, const char *matches)  {  	int ret = -1; | 
