diff options
author | Nikias Bassen | 2020-06-05 20:50:34 +0200 |
---|---|---|
committer | Nikias Bassen | 2020-06-05 20:50:34 +0200 |
commit | 489a673aeeef4706af3986d41c24ab434e77d7d5 (patch) | |
tree | 123022859215220cf7f10a483d02bffdf157a0ce /tools/idevicebackup.c | |
parent | 3aa4e243faa8198550cb2851cb6f0b9cbb293812 (diff) | |
download | libimobiledevice-489a673aeeef4706af3986d41c24ab434e77d7d5.tar.gz libimobiledevice-489a673aeeef4706af3986d41c24ab434e77d7d5.tar.bz2 |
tools: Unify --network command line switch and add it where missing
Diffstat (limited to 'tools/idevicebackup.c')
-rw-r--r-- | tools/idevicebackup.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 171ab7e..dfd7b8b 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -676,6 +676,7 @@ static void print_usage(int argc, char **argv) printf("\n"); printf("OPTIONS:\n"); printf(" -u, --udid UDID\ttarget specific device by UDID\n"); + printf(" -n, --network\t\tconnect to network device\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"); @@ -690,6 +691,7 @@ int main(int argc, char *argv[]) lockdownd_error_t ldret = LOCKDOWN_E_UNKNOWN_ERROR; int i; char* udid = NULL; + int use_network = 0; lockdownd_service_descriptor_t service = NULL; int cmd = -1; int is_full_backup = 0; @@ -729,6 +731,10 @@ int main(int argc, char *argv[]) udid = strdup(argv[i]); continue; } + else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--network")) { + use_network = 1; + continue; + } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { print_usage(argc, argv); return 0; @@ -783,20 +789,14 @@ int main(int argc, char *argv[]) printf("Backup directory is \"%s\"\n", backup_directory); - if (udid) { - ret = idevice_new(&device, udid); - if (ret != IDEVICE_E_SUCCESS) { - printf("No device found with udid %s, is it plugged in?\n", udid); - return -1; - } - } - else - { - ret = idevice_new(&device, NULL); - if (ret != IDEVICE_E_SUCCESS) { - printf("No device found, is it plugged in?\n"); - return -1; + ret = idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX); + if (ret != IDEVICE_E_SUCCESS) { + if (udid) { + printf("No device found with udid %s.\n", udid); + } else { + printf("No device found.\n"); } + return -1; } if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) { |