summaryrefslogtreecommitdiffstats
path: root/tools/idevicename.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-06-05 20:50:34 +0200
committerGravatar Nikias Bassen2020-06-05 20:50:34 +0200
commit489a673aeeef4706af3986d41c24ab434e77d7d5 (patch)
tree123022859215220cf7f10a483d02bffdf157a0ce /tools/idevicename.c
parent3aa4e243faa8198550cb2851cb6f0b9cbb293812 (diff)
downloadlibimobiledevice-489a673aeeef4706af3986d41c24ab434e77d7d5.tar.gz
libimobiledevice-489a673aeeef4706af3986d41c24ab434e77d7d5.tar.bz2
tools: Unify --network command line switch and add it where missing
Diffstat (limited to 'tools/idevicename.c')
-rw-r--r--tools/idevicename.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/idevicename.c b/tools/idevicename.c
index 5a34ea0..a87872b 100644
--- a/tools/idevicename.c
+++ b/tools/idevicename.c
@@ -44,8 +44,9 @@ static void print_usage(void)
printf("Display the device name or set it to NAME if specified.\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(" -n, --network\t\tconnect to network device\n");
+ printf(" -d, --debug\t\tenable communication debugging\n");
printf(" -h, --help\t\tprint usage information\n");
printf(" -v, --version\t\tprint version information\n");
printf("\n");
@@ -58,6 +59,7 @@ int main(int argc, char** argv)
int c = 0;
const struct option longopts[] = {
{ "udid", required_argument, NULL, 'u' },
+ { "network", no_argument, NULL, 'n' },
{ "debug", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
@@ -65,12 +67,13 @@ int main(int argc, char** argv)
};
int res = -1;
char* udid = NULL;
+ int use_network = 0;
#ifndef WIN32
signal(SIGPIPE, SIG_IGN);
#endif
- while ((c = getopt_long(argc, argv, "du:hv", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "du:hnv", longopts, NULL)) != -1) {
switch (c) {
case 'u':
if (!*optarg) {
@@ -81,6 +84,9 @@ int main(int argc, char** argv)
free(udid);
udid = strdup(optarg);
break;
+ case 'n':
+ use_network = 1;
+ break;
case 'h':
print_usage();
return 0;
@@ -105,8 +111,12 @@ int main(int argc, char** argv)
}
idevice_t device = NULL;
- if (idevice_new(&device, udid) != IDEVICE_E_SUCCESS) {
- fprintf(stderr, "ERROR: Could not connect to device\n");
+ if (idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX) != IDEVICE_E_SUCCESS) {
+ if (udid) {
+ fprintf(stderr, "ERROR: No device found with udid %s.\n", udid);
+ } else {
+ fprintf(stderr, "ERROR: No device found.\n");
+ }
return -1;
}