summaryrefslogtreecommitdiffstats
path: root/tools/idevicename.c
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/idevicename.c
parenta077067bf9458612d54157e3c875d065e3678a54 (diff)
downloadlibimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.gz
libimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.bz2
tools: Add --version command line switch
Diffstat (limited to 'tools/idevicename.c')
-rw-r--r--tools/idevicename.c24
1 files changed, 15 insertions, 9 deletions
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);