diff options
| author | 2020-06-05 18:42:20 +0200 | |
|---|---|---|
| committer | 2020-06-05 18:42:20 +0200 | |
| commit | 3aa4e243faa8198550cb2851cb6f0b9cbb293812 (patch) | |
| tree | 4ea94424d60f1f2e7852f148a41eaeb7e92657a5 /tools/idevicesetlocation.c | |
| parent | a077067bf9458612d54157e3c875d065e3678a54 (diff) | |
| download | libimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.gz libimobiledevice-3aa4e243faa8198550cb2851cb6f0b9cbb293812.tar.bz2 | |
tools: Add --version command line switch
Diffstat (limited to 'tools/idevicesetlocation.c')
| -rw-r--r-- | tools/idevicesetlocation.c | 24 |
1 files changed, 16 insertions, 8 deletions
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 | ||
| 63 | int main(int argc, char **argv) | 67 | int 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) { |
