summaryrefslogtreecommitdiffstats
path: root/tools/idevicepair.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevicepair.c')
-rw-r--r--tools/idevicepair.c28
1 files changed, 15 insertions, 13 deletions
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 {