summaryrefslogtreecommitdiffstats
path: root/tools/idevicename.c
diff options
context:
space:
mode:
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)
44 printf("Display the device name or set it to NAME if specified.\n"); 44 printf("Display the device name or set it to NAME if specified.\n");
45 printf("\n"); 45 printf("\n");
46 printf("OPTIONS:\n"); 46 printf("OPTIONS:\n");
47 printf(" -d, --debug\t\tenable communication debugging\n");
48 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 47 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
48 printf(" -n, --network\t\tconnect to network device\n");
49 printf(" -d, --debug\t\tenable communication debugging\n");
49 printf(" -h, --help\t\tprint usage information\n"); 50 printf(" -h, --help\t\tprint usage information\n");
50 printf(" -v, --version\t\tprint version information\n"); 51 printf(" -v, --version\t\tprint version information\n");
51 printf("\n"); 52 printf("\n");
@@ -58,6 +59,7 @@ int main(int argc, char** argv)
58 int c = 0; 59 int c = 0;
59 const struct option longopts[] = { 60 const struct option longopts[] = {
60 { "udid", required_argument, NULL, 'u' }, 61 { "udid", required_argument, NULL, 'u' },
62 { "network", no_argument, NULL, 'n' },
61 { "debug", no_argument, NULL, 'd' }, 63 { "debug", no_argument, NULL, 'd' },
62 { "help", no_argument, NULL, 'h' }, 64 { "help", no_argument, NULL, 'h' },
63 { "version", no_argument, NULL, 'v' }, 65 { "version", no_argument, NULL, 'v' },
@@ -65,12 +67,13 @@ int main(int argc, char** argv)
65 }; 67 };
66 int res = -1; 68 int res = -1;
67 char* udid = NULL; 69 char* udid = NULL;
70 int use_network = 0;
68 71
69#ifndef WIN32 72#ifndef WIN32
70 signal(SIGPIPE, SIG_IGN); 73 signal(SIGPIPE, SIG_IGN);
71#endif 74#endif
72 75
73 while ((c = getopt_long(argc, argv, "du:hv", longopts, NULL)) != -1) { 76 while ((c = getopt_long(argc, argv, "du:hnv", longopts, NULL)) != -1) {
74 switch (c) { 77 switch (c) {
75 case 'u': 78 case 'u':
76 if (!*optarg) { 79 if (!*optarg) {
@@ -81,6 +84,9 @@ int main(int argc, char** argv)
81 free(udid); 84 free(udid);
82 udid = strdup(optarg); 85 udid = strdup(optarg);
83 break; 86 break;
87 case 'n':
88 use_network = 1;
89 break;
84 case 'h': 90 case 'h':
85 print_usage(); 91 print_usage();
86 return 0; 92 return 0;
@@ -105,8 +111,12 @@ int main(int argc, char** argv)
105 } 111 }
106 112
107 idevice_t device = NULL; 113 idevice_t device = NULL;
108 if (idevice_new(&device, udid) != IDEVICE_E_SUCCESS) { 114 if (idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX) != IDEVICE_E_SUCCESS) {
109 fprintf(stderr, "ERROR: Could not connect to device\n"); 115 if (udid) {
116 fprintf(stderr, "ERROR: No device found with udid %s.\n", udid);
117 } else {
118 fprintf(stderr, "ERROR: No device found.\n");
119 }
110 return -1; 120 return -1;
111 } 121 }
112 122