summaryrefslogtreecommitdiffstats
path: root/tools/idevice_id.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevice_id.c')
-rw-r--r--tools/idevice_id.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/tools/idevice_id.c b/tools/idevice_id.c
index b746491..540a6f2 100644
--- a/tools/idevice_id.c
+++ b/tools/idevice_id.c
@@ -23,6 +23,8 @@
#include <config.h>
#endif
+#define TOOL_NAME "idevice_id"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -36,20 +38,25 @@
static void print_usage(int argc, char **argv, int is_error)
{
- char *name = NULL;
- name = strrchr(argv[0], '/');
+ char *name = strrchr(argv[0], '/');
fprintf(is_error ? stderr : stdout, "Usage: %s [OPTIONS] [UDID]\n", (name ? name + 1: argv[0]));
fprintf(is_error ? stderr : stdout,
- "Prints device name or a list of attached devices.\n\n" \
- " If UDID is given, the name of the connected device with that UDID" \
- " will be retrieved.\n\n" \
- " -l, --list list UDIDs of all devices attached via USB\n" \
- " -n, --network list UDIDs of all devices available via network\n" \
- " -d, --debug enable communication debugging\n" \
- " -h, --help prints usage information\n" \
- "\n" \
- "Homepage: <" PACKAGE_URL ">\n"
- );
+ "\n"
+ "List attached devices or print device name of given device.\n"
+ "\n" \
+ " If UDID is given, the name of the connected device with that UDID"
+ " will be retrieved.\n"
+ "\n" \
+ "OPTIONS:\n"
+ " -l, --list list UDIDs of all devices attached via USB\n"
+ " -n, --network list UDIDs of all devices available via network\n"
+ " -d, --debug enable communication debugging\n"
+ " -h, --help prints usage information\n"
+ " -v, --version prints version information\n"
+ "\n"
+ "Homepage: <" PACKAGE_URL ">\n"
+ "Bug Reports: <" PACKAGE_BUGREPORT ">\n"
+ );
}
int main(int argc, char **argv)
@@ -60,7 +67,7 @@ int main(int argc, char **argv)
char *device_name = NULL;
int ret = 0;
int i;
- int mode = MODE_SHOW_ID;
+ int mode = MODE_LIST_DEVICES;
int include_usb = 0;
int include_network = 0;
const char* udid = NULL;
@@ -71,10 +78,11 @@ int main(int argc, char **argv)
{ "help", no_argument, NULL, 'h' },
{ "list", no_argument, NULL, 'l' },
{ "network", no_argument, NULL, 'n' },
+ { "version", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0}
};
- while ((c = getopt_long(argc, argv, "dhln", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "dhlnv", longopts, NULL)) != -1) {
switch (c) {
case 'd':
idevice_set_debug_level(1);
@@ -90,6 +98,9 @@ int main(int argc, char **argv)
mode = MODE_LIST_DEVICES;
include_network = 1;
break;
+ case 'v':
+ printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
+ return 0;
default:
print_usage(argc, argv, 1);
exit(EXIT_FAILURE);
@@ -98,9 +109,11 @@ int main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (mode == MODE_SHOW_ID && argc != 1) {
- print_usage(argc + optind, argv - optind, 1);
- exit(EXIT_FAILURE);
+ if (argc == 1) {
+ mode = MODE_SHOW_ID;
+ } else if (argc == 0 && optind == 1) {
+ include_usb = 1;
+ include_network = 1;
}
udid = argv[0];
@@ -112,7 +125,7 @@ int main(int argc, char **argv)
return -2;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client, "idevice_id")) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client, TOOL_NAME)) {
idevice_free(device);
fprintf(stderr, "ERROR: Connecting to device failed!\n");
return -2;
@@ -147,7 +160,7 @@ int main(int argc, char **argv)
printf("%s", dev_list[i]->udid);
if (include_usb && include_network) {
if (dev_list[i]->conn_type == CONNECTION_NETWORK) {
- printf(" (WiFi)");
+ printf(" (Network)");
} else {
printf(" (USB)");
}