From 3aa4e243faa8198550cb2851cb6f0b9cbb293812 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 5 Jun 2020 18:42:20 +0200 Subject: tools: Add --version command line switch --- tools/idevicebackup2.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'tools/idevicebackup2.c') diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 382efc6..61302cc 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -24,6 +24,8 @@ #include #endif +#define TOOL_NAME "idevicebackup2" + #include #include #include @@ -346,7 +348,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, idevice_t d char *udid_uppercase = NULL; lockdownd_client_t lockdown = NULL; - if (lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2") != LOCKDOWN_E_SUCCESS) { + if (lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME) != LOCKDOWN_E_SUCCESS) { return NULL; } @@ -367,7 +369,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, idevice_t d plist_t app_dict = plist_new_dict(); plist_t installed_apps = plist_new_array(); instproxy_client_t ip = NULL; - if (instproxy_client_start_service(device, &ip, "idevicebackup2") == INSTPROXY_E_SUCCESS) { + if (instproxy_client_start_service(device, &ip, TOOL_NAME) == INSTPROXY_E_SUCCESS) { plist_t client_opts = instproxy_client_options_new(); instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL); instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "ApplicationSINF", "iTunesMetadata", NULL); @@ -376,7 +378,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, idevice_t d instproxy_browse(ip, client_opts, &apps); sbservices_client_t sbs = NULL; - if (sbservices_client_start_service(device, &sbs, "idevicebackup2") != SBSERVICES_E_SUCCESS) { + if (sbservices_client_start_service(device, &sbs, TOOL_NAME) != SBSERVICES_E_SUCCESS) { printf("Couldn't establish sbservices connection. Continuing anyway.\n"); } @@ -627,7 +629,7 @@ static void do_post_notification(idevice_t device, const char *notification) lockdownd_client_t lockdown = NULL; - if (lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2") != LOCKDOWN_E_SUCCESS) { + if (lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME) != LOCKDOWN_E_SUCCESS) { return; } @@ -1427,11 +1429,12 @@ static void print_usage(int argc, char **argv) printf(" cloud on|off\tenable or disable cloud use (requires iCloud account)\n"); printf("\n"); printf("OPTIONS:\n"); - printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --udid UDID\ttarget specific device by UDID\n"); printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); printf(" -i, --interactive\trequest passwords interactively\n"); + printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -h, --help\t\tprints usage information\n"); + printf(" -v, --version\t\tprints version information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); @@ -1501,6 +1504,10 @@ int main(int argc, char *argv[]) print_usage(argc, argv); return 0; } + else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { + printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); + return 0; + } else if (!strcmp(argv[i], "backup")) { cmd = CMD_BACKUP; } @@ -1746,7 +1753,7 @@ int main(int argc, char *argv[]) } lockdownd_client_t lockdown = NULL; - if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2"))) { + if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) { printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); idevice_free(device); return -1; @@ -2136,7 +2143,7 @@ checkpoint: uint8_t passcode_hint = 0; if (device_version >= DEVICE_VERSION(13,0,0)) { diagnostics_relay_client_t diag = NULL; - if (diagnostics_relay_client_start_service(device, &diag, "idevicebackup2") == DIAGNOSTICS_RELAY_E_SUCCESS) { + if (diagnostics_relay_client_start_service(device, &diag, TOOL_NAME) == DIAGNOSTICS_RELAY_E_SUCCESS) { plist_t dict = NULL; plist_t keys = plist_new_array(); plist_array_append_item(keys, plist_new_string("PasswordConfigured")); -- cgit v1.1-32-gdbae