diff options
| author | 2009-05-19 13:15:11 +0200 | |
|---|---|---|
| committer | 2009-05-19 07:30:34 -0700 | |
| commit | b61667e9eae1a588815453ccdaa8721e228cc0b8 (patch) | |
| tree | 7a14a6cb7af138abbca7be4bb822dda9df2dafb7 /dev/iphoneinfo.c | |
| parent | 34b8e4d575876ace41b91fb6e25a5fa9f9290608 (diff) | |
| download | libimobiledevice-b61667e9eae1a588815453ccdaa8721e228cc0b8.tar.gz libimobiledevice-b61667e9eae1a588815453ccdaa8721e228cc0b8.tar.bz2 | |
Adapted iphoneinfo and iphonesyslog to new API to allow device selection Added iphone_id tool to list devices attached and retrieve device name.
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'dev/iphoneinfo.c')
| -rw-r--r-- | dev/iphoneinfo.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 409ad2d..c28eb9e 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <usb.h> | ||
| 26 | 25 | ||
| 27 | #include <libiphone/libiphone.h> | 26 | #include <libiphone/libiphone.h> |
| 28 | 27 | ||
| @@ -37,7 +36,8 @@ int main(int argc, char *argv[]) | |||
| 37 | iphone_device_t phone = NULL; | 36 | iphone_device_t phone = NULL; |
| 38 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | 37 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; |
| 39 | int i; | 38 | int i; |
| 40 | int bus_n = -1, dev_n = -1; | 39 | char uuid[41]; |
| 40 | uuid[0] = 0; | ||
| 41 | 41 | ||
| 42 | /* parse cmdline args */ | 42 | /* parse cmdline args */ |
| 43 | for (i = 1; i < argc; i++) { | 43 | for (i = 1; i < argc; i++) { |
| @@ -45,11 +45,13 @@ int main(int argc, char *argv[]) | |||
| 45 | iphone_set_debug_mask(DBGMASK_ALL); | 45 | iphone_set_debug_mask(DBGMASK_ALL); |
| 46 | continue; | 46 | continue; |
| 47 | } | 47 | } |
| 48 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--usb")) { | 48 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { |
| 49 | if (sscanf(argv[++i], "%d,%d", &bus_n, &dev_n) < 2) { | 49 | i++; |
| 50 | if (!argv[i] || (strlen(argv[i]) != 40)) { | ||
| 50 | print_usage(argc, argv); | 51 | print_usage(argc, argv); |
| 51 | return 0; | 52 | return 0; |
| 52 | } | 53 | } |
| 54 | strcpy(uuid, argv[i]); | ||
| 53 | continue; | 55 | continue; |
| 54 | } | 56 | } |
| 55 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { | 57 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { |
| @@ -62,21 +64,21 @@ int main(int argc, char *argv[]) | |||
| 62 | } | 64 | } |
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | /* if (bus_n != -1) { | 67 | if (uuid[0] != 0) { |
| 66 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); | 68 | ret = iphone_get_device_by_uuid(&phone, uuid); |
| 67 | if (ret != IPHONE_E_SUCCESS) { | 69 | if (ret != IPHONE_E_SUCCESS) { |
| 68 | printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); | 70 | printf("No device found with uuid %s, is it plugged in?\n", uuid); |
| 69 | return -1; | 71 | return -1; |
| 70 | } | 72 | } |
| 71 | } | 73 | } |
| 72 | else | 74 | else |
| 73 | {*/ | 75 | { |
| 74 | ret = iphone_get_device(&phone); | 76 | ret = iphone_get_device(&phone); |
| 75 | if (ret != IPHONE_E_SUCCESS) { | 77 | if (ret != IPHONE_E_SUCCESS) { |
| 76 | printf("No device found, is it plugged in?\n"); | 78 | printf("No device found, is it plugged in?\n"); |
| 77 | return -1; | 79 | return -1; |
| 78 | } | 80 | } |
| 79 | /* }*/ | 81 | } |
| 80 | 82 | ||
| 81 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | 83 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { |
| 82 | iphone_free_device(phone); | 84 | iphone_free_device(phone); |
| @@ -108,7 +110,7 @@ void print_usage(int argc, char **argv) | |||
| 108 | printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); | 110 | printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); |
| 109 | printf("Show information about the first connected iPhone/iPod Touch.\n\n"); | 111 | printf("Show information about the first connected iPhone/iPod Touch.\n\n"); |
| 110 | printf(" -d, --debug\t\tenable communication debugging\n"); | 112 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 111 | printf(" -u, --usb=BUS,DEV\ttarget specific device by usb bus/dev number\n"); | 113 | printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); |
| 112 | printf(" -h, --help\t\tprints usage information\n"); | 114 | printf(" -h, --help\t\tprints usage information\n"); |
| 113 | printf("\n"); | 115 | printf("\n"); |
| 114 | } | 116 | } |
