summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-06-05 18:42:20 +0200
committerGravatar Nikias Bassen2020-06-05 18:42:20 +0200
commit3aa4e243faa8198550cb2851cb6f0b9cbb293812 (patch)
tree4ea94424d60f1f2e7852f148a41eaeb7e92657a5 /tools
parenta077067bf9458612d54157e3c875d065e3678a54 (diff)
downloadlibimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.gz
libimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.bz2
tools: Add --version command line switch
Diffstat (limited to 'tools')
-rw-r--r--tools/idevice_id.c11
-rw-r--r--tools/idevicebackup.c13
-rw-r--r--tools/idevicebackup2.c21
-rw-r--r--tools/idevicecrashreport.c11
-rw-r--r--tools/idevicedate.c11
-rw-r--r--tools/idevicedebug.c13
-rw-r--r--tools/idevicedebugserverproxy.c11
-rw-r--r--tools/idevicediagnostics.c12
-rw-r--r--tools/ideviceenterrecovery.c9
-rw-r--r--tools/ideviceimagemounter.c25
-rw-r--r--tools/ideviceinfo.c15
-rw-r--r--tools/idevicename.c24
-rw-r--r--tools/idevicenotificationproxy.c12
-rw-r--r--tools/idevicepair.c28
-rw-r--r--tools/ideviceprovision.c11
-rw-r--r--tools/idevicescreenshot.c11
-rw-r--r--tools/idevicesetlocation.c24
-rw-r--r--tools/idevicesyslog.c11
18 files changed, 198 insertions, 75 deletions
diff --git a/tools/idevice_id.c b/tools/idevice_id.c
index 7987705..7c1b3b4 100644
--- a/tools/idevice_id.c
+++ b/tools/idevice_id.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevice_id"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <stdlib.h> 30#include <stdlib.h>
@@ -51,6 +53,7 @@ static void print_usage(int argc, char **argv, int is_error)
51 " -n, --network list UDIDs of all devices available via network\n" \ 53 " -n, --network list UDIDs of all devices available via network\n" \
52 " -d, --debug enable communication debugging\n" \ 54 " -d, --debug enable communication debugging\n" \
53 " -h, --help prints usage information\n" \ 55 " -h, --help prints usage information\n" \
56 " -v, --version prints version information\n" \
54 "\n" \ 57 "\n" \
55 "Homepage: <" PACKAGE_URL ">\n" \ 58 "Homepage: <" PACKAGE_URL ">\n" \
56 "Bug Reports: <" PACKAGE_BUGREPORT ">\n" 59 "Bug Reports: <" PACKAGE_BUGREPORT ">\n"
@@ -76,10 +79,11 @@ int main(int argc, char **argv)
76 { "help", no_argument, NULL, 'h' }, 79 { "help", no_argument, NULL, 'h' },
77 { "list", no_argument, NULL, 'l' }, 80 { "list", no_argument, NULL, 'l' },
78 { "network", no_argument, NULL, 'n' }, 81 { "network", no_argument, NULL, 'n' },
82 { "version", no_argument, NULL, 'v' },
79 { NULL, 0, NULL, 0} 83 { NULL, 0, NULL, 0}
80 }; 84 };
81 85
82 while ((c = getopt_long(argc, argv, "dhln", longopts, NULL)) != -1) { 86 while ((c = getopt_long(argc, argv, "dhlnv", longopts, NULL)) != -1) {
83 switch (c) { 87 switch (c) {
84 case 'd': 88 case 'd':
85 idevice_set_debug_level(1); 89 idevice_set_debug_level(1);
@@ -95,6 +99,9 @@ int main(int argc, char **argv)
95 mode = MODE_LIST_DEVICES; 99 mode = MODE_LIST_DEVICES;
96 include_network = 1; 100 include_network = 1;
97 break; 101 break;
102 case 'v':
103 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
104 return 0;
98 default: 105 default:
99 print_usage(argc, argv, 1); 106 print_usage(argc, argv, 1);
100 exit(EXIT_FAILURE); 107 exit(EXIT_FAILURE);
@@ -117,7 +124,7 @@ int main(int argc, char **argv)
117 return -2; 124 return -2;
118 } 125 }
119 126
120 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client, "idevice_id")) { 127 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client, TOOL_NAME)) {
121 idevice_free(device); 128 idevice_free(device);
122 fprintf(stderr, "ERROR: Connecting to device failed!\n"); 129 fprintf(stderr, "ERROR: Connecting to device failed!\n");
123 return -2; 130 return -2;
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index c55301c..171ab7e 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -24,6 +24,8 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "idevicebackup"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <string.h> 30#include <string.h>
29#include <errno.h> 31#include <errno.h>
@@ -606,7 +608,7 @@ static void do_post_notification(const char *notification)
606 np_client_t np; 608 np_client_t np;
607 609
608 if (!client) { 610 if (!client) {
609 if (lockdownd_client_new_with_handshake(device, &client, "idevicebackup") != LOCKDOWN_E_SUCCESS) { 611 if (lockdownd_client_new_with_handshake(device, &client, TOOL_NAME) != LOCKDOWN_E_SUCCESS) {
610 return; 612 return;
611 } 613 }
612 } 614 }
@@ -673,9 +675,10 @@ static void print_usage(int argc, char **argv)
673 printf(" restore\tRestores a device backup from DIRECTORY.\n"); 675 printf(" restore\tRestores a device backup from DIRECTORY.\n");
674 printf("\n"); 676 printf("\n");
675 printf("OPTIONS:\n"); 677 printf("OPTIONS:\n");
676 printf(" -d, --debug\t\tenable communication debugging\n");
677 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 678 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
679 printf(" -d, --debug\t\tenable communication debugging\n");
678 printf(" -h, --help\t\tprints usage information\n"); 680 printf(" -h, --help\t\tprints usage information\n");
681 printf(" -v, --version\t\tprints version information\n");
679 printf("\n"); 682 printf("\n");
680 printf("Homepage: <" PACKAGE_URL ">\n"); 683 printf("Homepage: <" PACKAGE_URL ">\n");
681 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 684 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -730,6 +733,10 @@ int main(int argc, char *argv[])
730 print_usage(argc, argv); 733 print_usage(argc, argv);
731 return 0; 734 return 0;
732 } 735 }
736 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
737 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
738 return 0;
739 }
733 else if (!strcmp(argv[i], "backup")) { 740 else if (!strcmp(argv[i], "backup")) {
734 cmd = CMD_BACKUP; 741 cmd = CMD_BACKUP;
735 } 742 }
@@ -792,7 +799,7 @@ int main(int argc, char *argv[])
792 } 799 }
793 } 800 }
794 801
795 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, "idevicebackup"))) { 802 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) {
796 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); 803 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret);
797 idevice_free(device); 804 idevice_free(device);
798 return -1; 805 return -1;
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 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "idevicebackup2"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <string.h> 30#include <string.h>
29#include <errno.h> 31#include <errno.h>
@@ -346,7 +348,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, idevice_t d
346 char *udid_uppercase = NULL; 348 char *udid_uppercase = NULL;
347 349
348 lockdownd_client_t lockdown = NULL; 350 lockdownd_client_t lockdown = NULL;
349 if (lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2") != LOCKDOWN_E_SUCCESS) { 351 if (lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME) != LOCKDOWN_E_SUCCESS) {
350 return NULL; 352 return NULL;
351 } 353 }
352 354
@@ -367,7 +369,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, idevice_t d
367 plist_t app_dict = plist_new_dict(); 369 plist_t app_dict = plist_new_dict();
368 plist_t installed_apps = plist_new_array(); 370 plist_t installed_apps = plist_new_array();
369 instproxy_client_t ip = NULL; 371 instproxy_client_t ip = NULL;
370 if (instproxy_client_start_service(device, &ip, "idevicebackup2") == INSTPROXY_E_SUCCESS) { 372 if (instproxy_client_start_service(device, &ip, TOOL_NAME) == INSTPROXY_E_SUCCESS) {
371 plist_t client_opts = instproxy_client_options_new(); 373 plist_t client_opts = instproxy_client_options_new();
372 instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL); 374 instproxy_client_options_add(client_opts, "ApplicationType", "User", NULL);
373 instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "ApplicationSINF", "iTunesMetadata", NULL); 375 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
376 instproxy_browse(ip, client_opts, &apps); 378 instproxy_browse(ip, client_opts, &apps);
377 379
378 sbservices_client_t sbs = NULL; 380 sbservices_client_t sbs = NULL;
379 if (sbservices_client_start_service(device, &sbs, "idevicebackup2") != SBSERVICES_E_SUCCESS) { 381 if (sbservices_client_start_service(device, &sbs, TOOL_NAME) != SBSERVICES_E_SUCCESS) {
380 printf("Couldn't establish sbservices connection. Continuing anyway.\n"); 382 printf("Couldn't establish sbservices connection. Continuing anyway.\n");
381 } 383 }
382 384
@@ -627,7 +629,7 @@ static void do_post_notification(idevice_t device, const char *notification)
627 629
628 lockdownd_client_t lockdown = NULL; 630 lockdownd_client_t lockdown = NULL;
629 631
630 if (lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2") != LOCKDOWN_E_SUCCESS) { 632 if (lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME) != LOCKDOWN_E_SUCCESS) {
631 return; 633 return;
632 } 634 }
633 635
@@ -1427,11 +1429,12 @@ static void print_usage(int argc, char **argv)
1427 printf(" cloud on|off\tenable or disable cloud use (requires iCloud account)\n"); 1429 printf(" cloud on|off\tenable or disable cloud use (requires iCloud account)\n");
1428 printf("\n"); 1430 printf("\n");
1429 printf("OPTIONS:\n"); 1431 printf("OPTIONS:\n");
1430 printf(" -d, --debug\t\tenable communication debugging\n");
1431 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 1432 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
1432 printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); 1433 printf(" -s, --source UDID\tuse backup data from device specified by UDID\n");
1433 printf(" -i, --interactive\trequest passwords interactively\n"); 1434 printf(" -i, --interactive\trequest passwords interactively\n");
1435 printf(" -d, --debug\t\tenable communication debugging\n");
1434 printf(" -h, --help\t\tprints usage information\n"); 1436 printf(" -h, --help\t\tprints usage information\n");
1437 printf(" -v, --version\t\tprints version information\n");
1435 printf("\n"); 1438 printf("\n");
1436 printf("Homepage: <" PACKAGE_URL ">\n"); 1439 printf("Homepage: <" PACKAGE_URL ">\n");
1437 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 1440 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -1501,6 +1504,10 @@ int main(int argc, char *argv[])
1501 print_usage(argc, argv); 1504 print_usage(argc, argv);
1502 return 0; 1505 return 0;
1503 } 1506 }
1507 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
1508 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
1509 return 0;
1510 }
1504 else if (!strcmp(argv[i], "backup")) { 1511 else if (!strcmp(argv[i], "backup")) {
1505 cmd = CMD_BACKUP; 1512 cmd = CMD_BACKUP;
1506 } 1513 }
@@ -1746,7 +1753,7 @@ int main(int argc, char *argv[])
1746 } 1753 }
1747 1754
1748 lockdownd_client_t lockdown = NULL; 1755 lockdownd_client_t lockdown = NULL;
1749 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, "idevicebackup2"))) { 1756 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) {
1750 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); 1757 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret);
1751 idevice_free(device); 1758 idevice_free(device);
1752 return -1; 1759 return -1;
@@ -2136,7 +2143,7 @@ checkpoint:
2136 uint8_t passcode_hint = 0; 2143 uint8_t passcode_hint = 0;
2137 if (device_version >= DEVICE_VERSION(13,0,0)) { 2144 if (device_version >= DEVICE_VERSION(13,0,0)) {
2138 diagnostics_relay_client_t diag = NULL; 2145 diagnostics_relay_client_t diag = NULL;
2139 if (diagnostics_relay_client_start_service(device, &diag, "idevicebackup2") == DIAGNOSTICS_RELAY_E_SUCCESS) { 2146 if (diagnostics_relay_client_start_service(device, &diag, TOOL_NAME) == DIAGNOSTICS_RELAY_E_SUCCESS) {
2140 plist_t dict = NULL; 2147 plist_t dict = NULL;
2141 plist_t keys = plist_new_array(); 2148 plist_t keys = plist_new_array();
2142 plist_array_append_item(keys, plist_new_string("PasswordConfigured")); 2149 plist_array_append_item(keys, plist_new_string("PasswordConfigured"));
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 8600ad1..0fc40c6 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -24,6 +24,8 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "idevicecrashreport"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <stdlib.h> 30#include <stdlib.h>
29#include <string.h> 31#include <string.h>
@@ -306,11 +308,12 @@ static void print_usage(int argc, char **argv)
306 printf("Move crash reports from device to a local DIRECTORY.\n"); 308 printf("Move crash reports from device to a local DIRECTORY.\n");
307 printf("\n"); 309 printf("\n");
308 printf("OPTIONS:\n"); 310 printf("OPTIONS:\n");
311 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
309 printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n"); 312 printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n");
310 printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n"); 313 printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n");
311 printf(" -d, --debug\t\tenable communication debugging\n"); 314 printf(" -d, --debug\t\tenable communication debugging\n");
312 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
313 printf(" -h, --help\t\tprints usage information\n"); 315 printf(" -h, --help\t\tprints usage information\n");
316 printf(" -v, --version\t\tprints version information\n");
314 printf("\n"); 317 printf("\n");
315 printf("Homepage: <" PACKAGE_URL ">\n"); 318 printf("Homepage: <" PACKAGE_URL ">\n");
316 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 319 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -351,6 +354,10 @@ int main(int argc, char* argv[])
351 print_usage(argc, argv); 354 print_usage(argc, argv);
352 return 0; 355 return 0;
353 } 356 }
357 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
358 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
359 return 0;
360 }
354 else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--extract")) { 361 else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--extract")) {
355 extract_raw_crash_reports = 1; 362 extract_raw_crash_reports = 1;
356 continue; 363 continue;
@@ -392,7 +399,7 @@ int main(int argc, char* argv[])
392 return -1; 399 return -1;
393 } 400 }
394 401
395 lockdownd_error = lockdownd_client_new_with_handshake(device, &lockdownd, "idevicecrashreport"); 402 lockdownd_error = lockdownd_client_new_with_handshake(device, &lockdownd, TOOL_NAME);
396 if (lockdownd_error != LOCKDOWN_E_SUCCESS) { 403 if (lockdownd_error != LOCKDOWN_E_SUCCESS) {
397 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lockdownd_error); 404 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lockdownd_error);
398 idevice_free(device); 405 idevice_free(device);
diff --git a/tools/idevicedate.c b/tools/idevicedate.c
index 9c14fdf..e1fbc20 100644
--- a/tools/idevicedate.c
+++ b/tools/idevicedate.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicedate"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <stdlib.h> 29#include <stdlib.h>
28#include <string.h> 30#include <string.h>
@@ -56,11 +58,12 @@ static void print_usage(int argc, char **argv)
56 printf(" in the setup wizard screens before device activation.\n"); 58 printf(" in the setup wizard screens before device activation.\n");
57 printf("\n"); 59 printf("\n");
58 printf("OPTIONS:\n"); 60 printf("OPTIONS:\n");
59 printf(" -d, --debug\t\tenable communication debugging\n");
60 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 61 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
61 printf(" -s, --set TIMESTAMP\tset UTC time described by TIMESTAMP\n"); 62 printf(" -s, --set TIMESTAMP\tset UTC time described by TIMESTAMP\n");
62 printf(" -c, --sync\t\tset time of device to current system time\n"); 63 printf(" -c, --sync\t\tset time of device to current system time\n");
64 printf(" -d, --debug\t\tenable communication debugging\n");
63 printf(" -h, --help\t\tprints usage information\n"); 65 printf(" -h, --help\t\tprints usage information\n");
66 printf(" -v, --version\t\tprints version information\n");
64 printf("\n"); 67 printf("\n");
65 printf("Homepage: <" PACKAGE_URL ">\n"); 68 printf("Homepage: <" PACKAGE_URL ">\n");
66 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 69 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -129,6 +132,10 @@ int main(int argc, char *argv[])
129 print_usage(argc, argv); 132 print_usage(argc, argv);
130 return 0; 133 return 0;
131 } 134 }
135 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
136 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
137 return 0;
138 }
132 else { 139 else {
133 print_usage(argc, argv); 140 print_usage(argc, argv);
134 return 0; 141 return 0;
@@ -145,7 +152,7 @@ int main(int argc, char *argv[])
145 return -1; 152 return -1;
146 } 153 }
147 154
148 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, "idevicedate"))) { 155 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) {
149 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ldret); 156 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ldret);
150 result = -1; 157 result = -1;
151 goto cleanup; 158 goto cleanup;
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index b946d2c..66e997d 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicedebug"
27
26#include <signal.h> 28#include <signal.h>
27#include <stdio.h> 29#include <stdio.h>
28#include <stdlib.h> 30#include <stdlib.h>
@@ -193,10 +195,11 @@ static void print_usage(int argc, char **argv)
193 printf(" run BUNDLEID [ARGS...]\trun app with BUNDLEID and optional ARGS on device.\n"); 195 printf(" run BUNDLEID [ARGS...]\trun app with BUNDLEID and optional ARGS on device.\n");
194 printf("\n"); 196 printf("\n");
195 printf("The following OPTIONS are accepted:\n"); 197 printf("The following OPTIONS are accepted:\n");
196 printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n");
197 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 198 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
199 printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n");
198 printf(" -d, --debug\t\tenable communication debugging\n"); 200 printf(" -d, --debug\t\tenable communication debugging\n");
199 printf(" -h, --help\t\tprints usage information\n"); 201 printf(" -h, --help\t\tprints usage information\n");
202 printf(" -v, --version\t\tprints version information\n");
200 printf("\n"); 203 printf("\n");
201 printf("Homepage: <" PACKAGE_URL ">\n"); 204 printf("Homepage: <" PACKAGE_URL ">\n");
202 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 205 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -265,6 +268,10 @@ int main(int argc, char *argv[])
265 print_usage(argc, argv); 268 print_usage(argc, argv);
266 res = 0; 269 res = 0;
267 goto cleanup; 270 goto cleanup;
271 } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
272 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
273 res = 0;
274 goto cleanup;
268 } else if (!strcmp(argv[i], "run")) { 275 } else if (!strcmp(argv[i], "run")) {
269 cmd = CMD_RUN; 276 cmd = CMD_RUN;
270 277
@@ -313,7 +320,7 @@ int main(int argc, char *argv[])
313 case CMD_RUN: 320 case CMD_RUN:
314 default: 321 default:
315 /* get the path to the app and it's working directory */ 322 /* get the path to the app and it's working directory */
316 if (instproxy_client_start_service(device, &instproxy_client, "idevicerun") != INSTPROXY_E_SUCCESS) { 323 if (instproxy_client_start_service(device, &instproxy_client, TOOL_NAME) != INSTPROXY_E_SUCCESS) {
317 fprintf(stderr, "Could not start installation proxy service.\n"); 324 fprintf(stderr, "Could not start installation proxy service.\n");
318 goto cleanup; 325 goto cleanup;
319 } 326 }
@@ -334,7 +341,7 @@ int main(int argc, char *argv[])
334 } 341 }
335 342
336 /* start and connect to debugserver */ 343 /* start and connect to debugserver */
337 if (debugserver_client_start_service(device, &debugserver_client, "idevicerun") != DEBUGSERVER_E_SUCCESS) { 344 if (debugserver_client_start_service(device, &debugserver_client, TOOL_NAME) != DEBUGSERVER_E_SUCCESS) {
338 fprintf(stderr, 345 fprintf(stderr,
339 "Could not start com.apple.debugserver!\n" 346 "Could not start com.apple.debugserver!\n"
340 "Please make sure to mount the developer disk image first:\n" 347 "Please make sure to mount the developer disk image first:\n"
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 338a3c0..c0a0eff 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicedebugserverproxy"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <stdlib.h> 29#include <stdlib.h>
28#include <string.h> 30#include <string.h>
@@ -73,9 +75,10 @@ static void print_usage(int argc, char **argv)
73 printf("Proxy debugserver connection from device to a local socket at PORT.\n"); 75 printf("Proxy debugserver connection from device to a local socket at PORT.\n");
74 printf("\n"); 76 printf("\n");
75 printf("OPTIONS:\n"); 77 printf("OPTIONS:\n");
76 printf(" -d, --debug\t\tenable communication debugging\n");
77 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 78 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
79 printf(" -d, --debug\t\tenable communication debugging\n");
78 printf(" -h, --help\t\tprints usage information\n"); 80 printf(" -h, --help\t\tprints usage information\n");
81 printf(" -v, --version\t\tprints version information\n");
79 printf("\n"); 82 printf("\n");
80 printf("Homepage: <" PACKAGE_URL ">\n"); 83 printf("Homepage: <" PACKAGE_URL ">\n");
81 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 84 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -213,7 +216,7 @@ static void* connection_handler(void* data)
213 216
214 debug("%s: client_fd = %d\n", __func__, socket_info->client_fd); 217 debug("%s: client_fd = %d\n", __func__, socket_info->client_fd);
215 218
216 derr = debugserver_client_start_service(socket_info->device, &socket_info->debugserver_client, "idevicedebugserverproxy"); 219 derr = debugserver_client_start_service(socket_info->device, &socket_info->debugserver_client, TOOL_NAME);
217 if (derr != DEBUGSERVER_E_SUCCESS) { 220 if (derr != DEBUGSERVER_E_SUCCESS) {
218 fprintf(stderr, "Could not start debugserver on device!\nPlease make sure to mount a developer disk image first.\n"); 221 fprintf(stderr, "Could not start debugserver on device!\nPlease make sure to mount a developer disk image first.\n");
219 return NULL; 222 return NULL;
@@ -295,6 +298,10 @@ int main(int argc, char *argv[])
295 print_usage(argc, argv); 298 print_usage(argc, argv);
296 return EXIT_SUCCESS; 299 return EXIT_SUCCESS;
297 } 300 }
301 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
302 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
303 return EXIT_SUCCESS;
304 }
298 else if (atoi(argv[i]) > 0) { 305 else if (atoi(argv[i]) > 0) {
299 local_port = atoi(argv[i]); 306 local_port = atoi(argv[i]);
300 continue; 307 continue;
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 052bbed..153f9ac 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicediagnostics"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <stdlib.h> 30#include <stdlib.h>
@@ -98,6 +100,11 @@ int main(int argc, char **argv)
98 result = EXIT_SUCCESS; 100 result = EXIT_SUCCESS;
99 goto cleanup; 101 goto cleanup;
100 } 102 }
103 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
104 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
105 result = EXIT_SUCCESS;
106 goto cleanup;
107 }
101 else if (!strcmp(argv[i], "sleep")) { 108 else if (!strcmp(argv[i], "sleep")) {
102 cmd = CMD_SLEEP; 109 cmd = CMD_SLEEP;
103 } 110 }
@@ -193,7 +200,7 @@ int main(int argc, char **argv)
193 goto cleanup; 200 goto cleanup;
194 } 201 }
195 202
196 if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &lockdown_client, "idevicediagnostics"))) { 203 if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &lockdown_client, TOOL_NAME))) {
197 idevice_free(device); 204 idevice_free(device);
198 printf("ERROR: Could not connect to lockdownd, error code %d\n", ret); 205 printf("ERROR: Could not connect to lockdownd, error code %d\n", ret);
199 goto cleanup; 206 goto cleanup;
@@ -327,9 +334,10 @@ void print_usage(int argc, char **argv)
327 printf(" sleep\t\t\t\tput device into sleep mode (disconnects from host)\n"); 334 printf(" sleep\t\t\t\tput device into sleep mode (disconnects from host)\n");
328 printf("\n"); 335 printf("\n");
329 printf("The following OPTIONS are accepted:\n"); 336 printf("The following OPTIONS are accepted:\n");
330 printf(" -d, --debug\t\tenable communication debugging\n");
331 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 337 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
338 printf(" -d, --debug\t\tenable communication debugging\n");
332 printf(" -h, --help\t\tprints usage information\n"); 339 printf(" -h, --help\t\tprints usage information\n");
340 printf(" -v, --version\t\tprints version information\n");
333 printf("\n"); 341 printf("\n");
334 printf("Homepage: <" PACKAGE_URL ">\n"); 342 printf("Homepage: <" PACKAGE_URL ">\n");
335 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 343 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
diff --git a/tools/ideviceenterrecovery.c b/tools/ideviceenterrecovery.c
index 868ee7d..8d82929 100644
--- a/tools/ideviceenterrecovery.c
+++ b/tools/ideviceenterrecovery.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "ideviceenterrecovery"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <errno.h> 30#include <errno.h>
@@ -46,6 +48,7 @@ static void print_usage(int argc, char **argv)
46 printf("OPTIONS:\n"); 48 printf("OPTIONS:\n");
47 printf(" -d, --debug\t\tenable communication debugging\n"); 49 printf(" -d, --debug\t\tenable communication debugging\n");
48 printf(" -h, --help\t\tprints usage information\n"); 50 printf(" -h, --help\t\tprints usage information\n");
51 printf(" -v, --version\t\tprints version information\n");
49 printf("\n"); 52 printf("\n");
50 printf("Homepage: <" PACKAGE_URL ">\n"); 53 printf("Homepage: <" PACKAGE_URL ">\n");
51 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 54 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -73,6 +76,10 @@ int main(int argc, char *argv[])
73 print_usage(argc, argv); 76 print_usage(argc, argv);
74 return 0; 77 return 0;
75 } 78 }
79 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
80 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
81 return 0;
82 }
76 } 83 }
77 84
78 i--; 85 i--;
@@ -88,7 +95,7 @@ int main(int argc, char *argv[])
88 return -1; 95 return -1;
89 } 96 }
90 97
91 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new(device, &client, "ideviceenterrecovery"))) { 98 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new(device, &client, TOOL_NAME))) {
92 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); 99 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret);
93 idevice_free(device); 100 idevice_free(device);
94 return -1; 101 return -1;
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index 3f6f42e..df43d5a 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "ideviceimagemounter"
27
26#include <stdlib.h> 28#include <stdlib.h>
27#define _GNU_SOURCE 1 29#define _GNU_SOURCE 1
28#define __USE_GNU 1 30#define __USE_GNU 1
@@ -75,6 +77,7 @@ static void print_usage(int argc, char **argv)
75 printf(" -x, --xml\t\tUse XML output\n"); 77 printf(" -x, --xml\t\tUse XML output\n");
76 printf(" -d, --debug\t\tenable communication debugging\n"); 78 printf(" -d, --debug\t\tenable communication debugging\n");
77 printf(" -h, --help\t\tprints usage information\n"); 79 printf(" -h, --help\t\tprints usage information\n");
80 printf(" -v, --version\t\tprints version information\n");
78 printf("\n"); 81 printf("\n");
79 printf("Homepage: <" PACKAGE_URL ">\n"); 82 printf("Homepage: <" PACKAGE_URL ">\n");
80 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 83 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -83,18 +86,19 @@ static void print_usage(int argc, char **argv)
83static void parse_opts(int argc, char **argv) 86static void parse_opts(int argc, char **argv)
84{ 87{
85 static struct option longopts[] = { 88 static struct option longopts[] = {
86 {"help", no_argument, NULL, 'h'}, 89 { "help", no_argument, NULL, 'h'},
87 {"udid", required_argument, NULL, 'u'}, 90 { "udid", required_argument, NULL, 'u'},
88 {"list", no_argument, NULL, 'l'}, 91 { "list", no_argument, NULL, 'l'},
89 {"imagetype", required_argument, NULL, 't'}, 92 { "imagetype", required_argument, NULL, 't'},
90 {"xml", no_argument, NULL, 'x'}, 93 { "xml", no_argument, NULL, 'x'},
91 {"debug", no_argument, NULL, 'd'}, 94 { "debug", no_argument, NULL, 'd'},
92 {NULL, 0, NULL, 0} 95 { "version", no_argument, NULL, 'v' },
96 { NULL, 0, NULL, 0 }
93 }; 97 };
94 int c; 98 int c;
95 99
96 while (1) { 100 while (1) {
97 c = getopt_long(argc, argv, "hu:lt:xd", longopts, NULL); 101 c = getopt_long(argc, argv, "hu:lt:xdv", longopts, NULL);
98 if (c == -1) { 102 if (c == -1) {
99 break; 103 break;
100 } 104 }
@@ -126,6 +130,9 @@ static void parse_opts(int argc, char **argv)
126 case 'd': 130 case 'd':
127 idevice_set_debug_level(1); 131 idevice_set_debug_level(1);
128 break; 132 break;
133 case 'v':
134 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
135 exit(0);
129 default: 136 default:
130 print_usage(argc, argv); 137 print_usage(argc, argv);
131 exit(2); 138 exit(2);
@@ -189,7 +196,7 @@ int main(int argc, char **argv)
189 return -1; 196 return -1;
190 } 197 }
191 198
192 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lckd, "ideviceimagemounter"))) { 199 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lckd, TOOL_NAME))) {
193 printf("ERROR: Could not connect to lockdown, error code %d.\n", ldret); 200 printf("ERROR: Could not connect to lockdown, error code %d.\n", ldret);
194 goto leave; 201 goto leave;
195 } 202 }
diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c
index 0697990..9b13ab8 100644
--- a/tools/ideviceinfo.c
+++ b/tools/ideviceinfo.c
@@ -24,6 +24,8 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "ideviceinfo"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <string.h> 30#include <string.h>
29#include <errno.h> 31#include <errno.h>
@@ -97,14 +99,15 @@ static void print_usage(int argc, char **argv, int is_error)
97 "Show information about a connected device.\n" \ 99 "Show information about a connected device.\n" \
98 "\n" \ 100 "\n" \
99 "OPTIONS:\n" \ 101 "OPTIONS:\n" \
100 " -s, --simple use a simple connection to avoid auto-pairing with the device\n" \
101 " -u, --udid UDID target specific device by UDID\n" \ 102 " -u, --udid UDID target specific device by UDID\n" \
102 " -n, --network connect to network device even if available via USB\n" \ 103 " -n, --network connect to network device even if available via USB\n" \
104 " -s, --simple use a simple connection to avoid auto-pairing with the device\n" \
103 " -q, --domain NAME set domain of query to NAME. Default: None\n" \ 105 " -q, --domain NAME set domain of query to NAME. Default: None\n" \
104 " -k, --key NAME only query key specified by NAME. Default: All keys.\n" \ 106 " -k, --key NAME only query key specified by NAME. Default: All keys.\n" \
105 " -x, --xml output information as xml plist instead of key/value pairs\n" \ 107 " -x, --xml output information as xml plist instead of key/value pairs\n" \
106 " -h, --help prints usage information\n" \ 108 " -h, --help prints usage information\n" \
107 " -d, --debug enable communication debugging\n" \ 109 " -d, --debug enable communication debugging\n" \
110 " -v, --version prints version information\n" \
108 "\n" 111 "\n"
109 ); 112 );
110 fprintf(is_error ? stderr : stdout, "Known domains are:\n\n"); 113 fprintf(is_error ? stderr : stdout, "Known domains are:\n\n");
@@ -144,6 +147,7 @@ int main(int argc, char *argv[])
144 { "key", required_argument, NULL, 'k' }, 147 { "key", required_argument, NULL, 'k' },
145 { "simple", no_argument, NULL, 's' }, 148 { "simple", no_argument, NULL, 's' },
146 { "xml", no_argument, NULL, 'x' }, 149 { "xml", no_argument, NULL, 'x' },
150 { "version", no_argument, NULL, 'v' },
147 { NULL, 0, NULL, 0} 151 { NULL, 0, NULL, 0}
148 }; 152 };
149 153
@@ -151,7 +155,7 @@ int main(int argc, char *argv[])
151 signal(SIGPIPE, SIG_IGN); 155 signal(SIGPIPE, SIG_IGN);
152#endif 156#endif
153 157
154 while ((c = getopt_long(argc, argv, "dhu:nq:k:sx", longopts, NULL)) != -1) { 158 while ((c = getopt_long(argc, argv, "dhu:nq:k:sxv", longopts, NULL)) != -1) {
155 switch (c) { 159 switch (c) {
156 case 'd': 160 case 'd':
157 idevice_set_debug_level(1); 161 idevice_set_debug_level(1);
@@ -195,6 +199,9 @@ int main(int argc, char *argv[])
195 case 'h': 199 case 'h':
196 print_usage(argc, argv, 0); 200 print_usage(argc, argv, 0);
197 return 0; 201 return 0;
202 case 'v':
203 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
204 return 0;
198 default: 205 default:
199 print_usage(argc, argv, 1); 206 print_usage(argc, argv, 1);
200 return 2; 207 return 2;
@@ -215,8 +222,8 @@ int main(int argc, char *argv[])
215 } 222 }
216 223
217 if (LOCKDOWN_E_SUCCESS != (ldret = simple ? 224 if (LOCKDOWN_E_SUCCESS != (ldret = simple ?
218 lockdownd_client_new(device, &client, "ideviceinfo"): 225 lockdownd_client_new(device, &client, TOOL_NAME):
219 lockdownd_client_new_with_handshake(device, &client, "ideviceinfo"))) { 226 lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) {
220 fprintf(stderr, "ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ldret), ldret); 227 fprintf(stderr, "ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ldret), ldret);
221 idevice_free(device); 228 idevice_free(device);
222 return -1; 229 return -1;
diff --git a/tools/idevicename.c b/tools/idevicename.c
index af80dcc..5a34ea0 100644
--- a/tools/idevicename.c
+++ b/tools/idevicename.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicename"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <unistd.h> 30#include <unistd.h>
@@ -45,6 +47,7 @@ static void print_usage(void)
45 printf(" -d, --debug\t\tenable communication debugging\n"); 47 printf(" -d, --debug\t\tenable communication debugging\n");
46 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 48 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
47 printf(" -h, --help\t\tprint usage information\n"); 49 printf(" -h, --help\t\tprint usage information\n");
50 printf(" -v, --version\t\tprint version information\n");
48 printf("\n"); 51 printf("\n");
49 printf("Homepage: <" PACKAGE_URL ">\n"); 52 printf("Homepage: <" PACKAGE_URL ">\n");
50 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 53 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -52,22 +55,22 @@ static void print_usage(void)
52 55
53int main(int argc, char** argv) 56int main(int argc, char** argv)
54{ 57{
55 int res = -1;
56 char* udid = NULL;
57
58 int c = 0; 58 int c = 0;
59 int optidx = 0;
60 const struct option longopts[] = { 59 const struct option longopts[] = {
61 { "udid", required_argument, NULL, 'u' }, 60 { "udid", required_argument, NULL, 'u' },
62 { "help", no_argument, NULL, 'h' }, 61 { "debug", no_argument, NULL, 'd' },
62 { "help", no_argument, NULL, 'h' },
63 { "version", no_argument, NULL, 'v' },
63 { NULL, 0, NULL, 0} 64 { NULL, 0, NULL, 0}
64 }; 65 };
66 int res = -1;
67 char* udid = NULL;
65 68
66#ifndef WIN32 69#ifndef WIN32
67 signal(SIGPIPE, SIG_IGN); 70 signal(SIGPIPE, SIG_IGN);
68#endif 71#endif
69 72
70 while ((c = getopt_long(argc, argv, "du:h", longopts, &optidx)) != -1) { 73 while ((c = getopt_long(argc, argv, "du:hv", longopts, NULL)) != -1) {
71 switch (c) { 74 switch (c) {
72 case 'u': 75 case 'u':
73 if (!*optarg) { 76 if (!*optarg) {
@@ -84,9 +87,12 @@ int main(int argc, char** argv)
84 case 'd': 87 case 'd':
85 idevice_set_debug_level(1); 88 idevice_set_debug_level(1);
86 break; 89 break;
90 case 'v':
91 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
92 return 0;
87 default: 93 default:
88 print_usage(); 94 print_usage();
89 return -1; 95 return 2;
90 } 96 }
91 } 97 }
92 98
@@ -105,7 +111,7 @@ int main(int argc, char** argv)
105 } 111 }
106 112
107 lockdownd_client_t lockdown = NULL; 113 lockdownd_client_t lockdown = NULL;
108 lockdownd_error_t lerr = lockdownd_client_new_with_handshake(device, &lockdown, "idevicename"); 114 lockdownd_error_t lerr = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME);
109 if (lerr != LOCKDOWN_E_SUCCESS) { 115 if (lerr != LOCKDOWN_E_SUCCESS) {
110 idevice_free(device); 116 idevice_free(device);
111 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lerr); 117 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lerr);
diff --git a/tools/idevicenotificationproxy.c b/tools/idevicenotificationproxy.c
index 45744bc..15b63a3 100644
--- a/tools/idevicenotificationproxy.c
+++ b/tools/idevicenotificationproxy.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicenotificationproxy"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <errno.h> 30#include <errno.h>
@@ -71,9 +73,10 @@ static void print_usage(int argc, char **argv)
71 printf(" observe ID [...]\tobserve notification IDs in the foreground until CTRL+C or signal is received\n"); 73 printf(" observe ID [...]\tobserve notification IDs in the foreground until CTRL+C or signal is received\n");
72 printf("\n"); 74 printf("\n");
73 printf("The following OPTIONS are accepted:\n"); 75 printf("The following OPTIONS are accepted:\n");
74 printf(" -d, --debug\t\tenable communication debugging\n");
75 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 76 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
77 printf(" -d, --debug\t\tenable communication debugging\n");
76 printf(" -h, --help\t\tprints usage information\n"); 78 printf(" -h, --help\t\tprints usage information\n");
79 printf(" -v, --version\t\tprints version information\n");
77 printf("\n"); 80 printf("\n");
78 printf("Homepage: <" PACKAGE_URL ">\n"); 81 printf("Homepage: <" PACKAGE_URL ">\n");
79 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 82 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -130,6 +133,11 @@ int main(int argc, char *argv[])
130 result = 0; 133 result = 0;
131 goto cleanup; 134 goto cleanup;
132 } 135 }
136 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
137 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
138 result = 0;
139 goto cleanup;
140 }
133 else if (!strcmp(argv[i], "post") || !strcmp(argv[i], "observe")) { 141 else if (!strcmp(argv[i], "post") || !strcmp(argv[i], "observe")) {
134 cmd = CMD_POST; 142 cmd = CMD_POST;
135 if (!strcmp(argv[i], "observe")) { 143 if (!strcmp(argv[i], "observe")) {
@@ -186,7 +194,7 @@ int main(int argc, char *argv[])
186 goto cleanup; 194 goto cleanup;
187 } 195 }
188 196
189 if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &client, "idevicenotificationproxy"))) { 197 if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) {
190 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ret); 198 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ret);
191 goto cleanup; 199 goto cleanup;
192 } 200 }
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index 99c7b7c..de631a0 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -24,6 +24,8 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "idevicepair"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <string.h> 30#include <string.h>
29#include <stdlib.h> 31#include <stdlib.h>
@@ -78,9 +80,10 @@ static void print_usage(int argc, char **argv)
78 printf(" list list devices paired with this host\n"); 80 printf(" list list devices paired with this host\n");
79 printf("\n"); 81 printf("\n");
80 printf("The following OPTIONS are accepted:\n"); 82 printf("The following OPTIONS are accepted:\n");
81 printf(" -d, --debug enable communication debugging\n");
82 printf(" -u, --udid UDID target specific device by UDID\n"); 83 printf(" -u, --udid UDID target specific device by UDID\n");
84 printf(" -d, --debug enable communication debugging\n");
83 printf(" -h, --help prints usage information\n"); 85 printf(" -h, --help prints usage information\n");
86 printf(" -v, --version prints version information\n");
84 printf("\n"); 87 printf("\n");
85 printf("Homepage: <" PACKAGE_URL ">\n"); 88 printf("Homepage: <" PACKAGE_URL ">\n");
86 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 89 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -88,20 +91,16 @@ static void print_usage(int argc, char **argv)
88 91
89static void parse_opts(int argc, char **argv) 92static void parse_opts(int argc, char **argv)
90{ 93{
94 int c = 0;
91 static struct option longopts[] = { 95 static struct option longopts[] = {
92 {"help", no_argument, NULL, 'h'}, 96 { "help", no_argument, NULL, 'h' },
93 {"udid", required_argument, NULL, 'u'}, 97 { "udid", required_argument, NULL, 'u' },
94 {"debug", no_argument, NULL, 'd'}, 98 { "debug", no_argument, NULL, 'd' },
95 {NULL, 0, NULL, 0} 99 { "version", no_argument, NULL, 'v' },
100 { NULL, 0, NULL, 0}
96 }; 101 };
97 int c;
98
99 while (1) {
100 c = getopt_long(argc, argv, "hu:d", longopts, (int*)0);
101 if (c == -1) {
102 break;
103 }
104 102
103 while ((c = getopt_long(argc, argv, "hu:dv", longopts, NULL)) != -1) {
105 switch (c) { 104 switch (c) {
106 case 'h': 105 case 'h':
107 print_usage(argc, argv); 106 print_usage(argc, argv);
@@ -119,6 +118,9 @@ static void parse_opts(int argc, char **argv)
119 case 'd': 118 case 'd':
120 idevice_set_debug_level(1); 119 idevice_set_debug_level(1);
121 break; 120 break;
121 case 'v':
122 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
123 exit(EXIT_SUCCESS);
122 default: 124 default:
123 print_usage(argc, argv); 125 print_usage(argc, argv);
124 exit(EXIT_SUCCESS); 126 exit(EXIT_SUCCESS);
@@ -280,7 +282,7 @@ int main(int argc, char **argv)
280 case OP_VALIDATE: 282 case OP_VALIDATE:
281 lockdownd_client_free(client); 283 lockdownd_client_free(client);
282 client = NULL; 284 client = NULL;
283 lerr = lockdownd_client_new_with_handshake(device, &client, "idevicepair"); 285 lerr = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME);
284 if (lerr == LOCKDOWN_E_SUCCESS) { 286 if (lerr == LOCKDOWN_E_SUCCESS) {
285 printf("SUCCESS: Validated pairing with device %s\n", udid); 287 printf("SUCCESS: Validated pairing with device %s\n", udid);
286 } else { 288 } else {
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 4b96821..8cf3de6 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -24,6 +24,8 @@
24#include <config.h> 24#include <config.h>
25#endif 25#endif
26 26
27#define TOOL_NAME "ideviceprovision"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <stdlib.h> 30#include <stdlib.h>
29#include <string.h> 31#include <string.h>
@@ -69,10 +71,11 @@ static void print_usage(int argc, char **argv)
69 printf(" \tspecified by FILE.\n"); 71 printf(" \tspecified by FILE.\n");
70 printf("\n"); 72 printf("\n");
71 printf("The following OPTIONS are accepted:\n"); 73 printf("The following OPTIONS are accepted:\n");
72 printf(" -d, --debug enable communication debugging\n");
73 printf(" -u, --udid UDID target specific device by UDID\n"); 74 printf(" -u, --udid UDID target specific device by UDID\n");
74 printf(" -x, --xml print XML output when using the 'dump' command\n"); 75 printf(" -x, --xml print XML output when using the 'dump' command\n");
76 printf(" -d, --debug enable communication debugging\n");
75 printf(" -h, --help prints usage information\n"); 77 printf(" -h, --help prints usage information\n");
78 printf(" -v, --version prints version information\n");
76 printf("\n"); 79 printf("\n");
77 printf("Homepage: <" PACKAGE_URL ">\n"); 80 printf("Homepage: <" PACKAGE_URL ">\n");
78 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 81 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -376,6 +379,10 @@ int main(int argc, char *argv[])
376 print_usage(argc, argv); 379 print_usage(argc, argv);
377 return 0; 380 return 0;
378 } 381 }
382 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
383 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
384 return 0;
385 }
379 else { 386 else {
380 print_usage(argc, argv); 387 print_usage(argc, argv);
381 return 0; 388 return 0;
@@ -440,7 +447,7 @@ int main(int argc, char *argv[])
440 return -1; 447 return -1;
441 } 448 }
442 449
443 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, "ideviceprovision"))) { 450 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) {
444 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ldret); 451 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ldret);
445 idevice_free(device); 452 idevice_free(device);
446 return -1; 453 return -1;
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index d91e8f4..c9dc0ef 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -23,6 +23,8 @@
23#include <config.h> 23#include <config.h>
24#endif 24#endif
25 25
26#define TOOL_NAME "idevicescreenshot"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <string.h> 29#include <string.h>
28#include <stdlib.h> 30#include <stdlib.h>
@@ -72,6 +74,10 @@ int main(int argc, char **argv)
72 print_usage(argc, argv); 74 print_usage(argc, argv);
73 return 0; 75 return 0;
74 } 76 }
77 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
78 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
79 return 0;
80 }
75 else if (argv[i][0] != '-' && !filename) { 81 else if (argv[i][0] != '-' && !filename) {
76 filename = strdup(argv[i]); 82 filename = strdup(argv[i]);
77 continue; 83 continue;
@@ -91,7 +97,7 @@ int main(int argc, char **argv)
91 return -1; 97 return -1;
92 } 98 }
93 99
94 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lckd, NULL))) { 100 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lckd, TOOL_NAME))) {
95 idevice_free(device); 101 idevice_free(device);
96 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); 102 printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret);
97 return -1; 103 return -1;
@@ -167,9 +173,10 @@ void print_usage(int argc, char **argv)
167 printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); 173 printf("NOTE: A mounted developer disk image is required on the device, otherwise\n");
168 printf("the screenshotr service is not available.\n"); 174 printf("the screenshotr service is not available.\n");
169 printf("\n"); 175 printf("\n");
170 printf(" -d, --debug\t\tenable communication debugging\n");
171 printf(" -u, --udid UDID\ttarget specific device by UDID\n"); 176 printf(" -u, --udid UDID\ttarget specific device by UDID\n");
177 printf(" -d, --debug\t\tenable communication debugging\n");
172 printf(" -h, --help\t\tprints usage information\n"); 178 printf(" -h, --help\t\tprints usage information\n");
179 printf(" -v, --version\t\tprints version information\n");
173 printf("\n"); 180 printf("\n");
174 printf("Homepage: <" PACKAGE_URL ">\n"); 181 printf("Homepage: <" PACKAGE_URL ">\n");
175 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 182 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
diff --git a/tools/idevicesetlocation.c b/tools/idevicesetlocation.c
index 47fc7da..47f15ca 100644
--- a/tools/idevicesetlocation.c
+++ b/tools/idevicesetlocation.c
@@ -21,6 +21,9 @@
21#ifdef HAVE_CONFIG_H 21#ifdef HAVE_CONFIG_H
22#include <config.h> 22#include <config.h>
23#endif 23#endif
24
25#define TOOL_NAME "idevicesetlocation"
26
24#include <stdio.h> 27#include <stdio.h>
25#include <stdlib.h> 28#include <stdlib.h>
26#include <stdint.h> 29#include <stdint.h>
@@ -52,8 +55,9 @@ static void print_usage(int argc, char **argv, int is_error)
52 "OPTIONS:\n" \ 55 "OPTIONS:\n" \
53 " -u, --udid UDID target specific device by UDID\n" \ 56 " -u, --udid UDID target specific device by UDID\n" \
54 " -n, --network connect to network device even if available via USB\n" \ 57 " -n, --network connect to network device even if available via USB\n" \
55 " -h, --help prints usage information\n" \
56 " -d, --debug enable communication debugging\n" \ 58 " -d, --debug enable communication debugging\n" \
59 " -h, --help prints usage information\n" \
60 " -v, --version prints version information\n" \
57 "\n" \ 61 "\n" \
58 "Homepage: <" PACKAGE_URL ">\n" \ 62 "Homepage: <" PACKAGE_URL ">\n" \
59 "Bug Reports: <" PACKAGE_BUGREPORT ">\n" 63 "Bug Reports: <" PACKAGE_BUGREPORT ">\n"
@@ -62,19 +66,20 @@ static void print_usage(int argc, char **argv, int is_error)
62 66
63int main(int argc, char **argv) 67int main(int argc, char **argv)
64{ 68{
69 int c = 0;
65 const struct option longopts[] = { 70 const struct option longopts[] = {
66 { "help", no_argument, NULL, 'h' }, 71 { "help", no_argument, NULL, 'h' },
67 { "udid", required_argument, NULL, 'u' }, 72 { "udid", required_argument, NULL, 'u' },
68 { "debug", no_argument, NULL, 'd' }, 73 { "debug", no_argument, NULL, 'd' },
69 { "network", no_argument, NULL, 'n' }, 74 { "network", no_argument, NULL, 'n' },
75 { "version", no_argument, NULL, 'v' },
70 { NULL, 0, NULL, 0} 76 { NULL, 0, NULL, 0}
71 }; 77 };
72 uint32_t mode = 0; 78 uint32_t mode = 0;
73 char *udid = NULL; 79 char *udid = NULL;
74 enum idevice_options lookup_opts = IDEVICE_LOOKUP_USBMUX | IDEVICE_LOOKUP_NETWORK; 80 enum idevice_options lookup_opts = IDEVICE_LOOKUP_USBMUX | IDEVICE_LOOKUP_NETWORK;
75 81
76 int c = 0; 82 while ((c = getopt_long(argc, argv, "dhu:nv", longopts, NULL)) != -1) {
77 while ((c = getopt_long(argc, argv, "dhu:n", longopts, NULL)) != -1) {
78 switch (c) { 83 switch (c) {
79 case 'd': 84 case 'd':
80 idevice_set_debug_level(1); 85 idevice_set_debug_level(1);
@@ -94,6 +99,9 @@ int main(int argc, char **argv)
94 case 'h': 99 case 'h':
95 print_usage(argc, argv, 0); 100 print_usage(argc, argv, 0);
96 return 0; 101 return 0;
102 case 'v':
103 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
104 return 0;
97 default: 105 default:
98 print_usage(argc, argv, 1); 106 print_usage(argc, argv, 1);
99 return 2; 107 return 2;
@@ -131,7 +139,7 @@ int main(int argc, char **argv)
131 } 139 }
132 140
133 lockdownd_client_t lockdown; 141 lockdownd_client_t lockdown;
134 lockdownd_client_new_with_handshake(device, &lockdown, NULL); 142 lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME);
135 143
136 lockdownd_service_descriptor_t svc = NULL; 144 lockdownd_service_descriptor_t svc = NULL;
137 if (lockdownd_start_service(lockdown, DT_SIMULATELOCATION_SERVICE, &svc) != LOCKDOWN_E_SUCCESS) { 145 if (lockdownd_start_service(lockdown, DT_SIMULATELOCATION_SERVICE, &svc) != LOCKDOWN_E_SUCCESS) {
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 54699a0..acbcd74 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -24,6 +24,8 @@
24#include "config.h" 24#include "config.h"
25#endif 25#endif
26 26
27#define TOOL_NAME "idevicesyslog"
28
27#include <stdio.h> 29#include <stdio.h>
28#include <string.h> 30#include <string.h>
29#include <errno.h> 31#include <errno.h>
@@ -408,7 +410,7 @@ static int start_logging(void)
408 } 410 }
409 411
410 lockdownd_client_t lockdown = NULL; 412 lockdownd_client_t lockdown = NULL;
411 lockdownd_error_t lerr = lockdownd_client_new_with_handshake(device, &lockdown, "idevicesyslog"); 413 lockdownd_error_t lerr = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME);
412 if (lerr != LOCKDOWN_E_SUCCESS) { 414 if (lerr != LOCKDOWN_E_SUCCESS) {
413 fprintf(stderr, "ERROR: Could not connect to lockdownd: %d\n", lerr); 415 fprintf(stderr, "ERROR: Could not connect to lockdownd: %d\n", lerr);
414 idevice_free(device); 416 idevice_free(device);
@@ -528,6 +530,7 @@ static void print_usage(int argc, char **argv, int is_error)
528 " -x, --exit exit when device disconnects\n" \ 530 " -x, --exit exit when device disconnects\n" \
529 " -h, --help prints usage information\n" \ 531 " -h, --help prints usage information\n" \
530 " -d, --debug enable communication debugging\n" \ 532 " -d, --debug enable communication debugging\n" \
533 " -v, --version prints version information\n" \
531 " --no-colors disable colored output\n" \ 534 " --no-colors disable colored output\n" \
532 "\n" \ 535 "\n" \
533 "FILTER OPTIONS:\n" \ 536 "FILTER OPTIONS:\n" \
@@ -581,6 +584,7 @@ int main(int argc, char *argv[])
581 { "no-kernel", no_argument, NULL, 'K' }, 584 { "no-kernel", no_argument, NULL, 'K' },
582 { "quiet-list", no_argument, NULL, 1 }, 585 { "quiet-list", no_argument, NULL, 1 },
583 { "no-colors", no_argument, NULL, 2 }, 586 { "no-colors", no_argument, NULL, 2 },
587 { "version", no_argument, NULL, 'v' },
584 { NULL, 0, NULL, 0} 588 { NULL, 0, NULL, 0}
585 }; 589 };
586 590
@@ -591,7 +595,7 @@ int main(int argc, char *argv[])
591 signal(SIGPIPE, SIG_IGN); 595 signal(SIGPIPE, SIG_IGN);
592#endif 596#endif
593 597
594 while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkK", longopts, NULL)) != -1) { 598 while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkKv", longopts, NULL)) != -1) {
595 switch (c) { 599 switch (c) {
596 case 'd': 600 case 'd':
597 idevice_set_debug_level(1); 601 idevice_set_debug_level(1);
@@ -693,6 +697,9 @@ int main(int argc, char *argv[])
693 case 2: 697 case 2:
694 no_colors = 1; 698 no_colors = 1;
695 break; 699 break;
700 case 'v':
701 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
702 return 0;
696 default: 703 default:
697 print_usage(argc, argv, 1); 704 print_usage(argc, argv, 1);
698 return 2; 705 return 2;