summaryrefslogtreecommitdiffstats
path: root/dev/iphone_id.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-07-28 10:58:50 +0200
committerGravatar Matt Colyer2009-07-28 21:32:13 -0700
commitd089bc54e88d7fa70be9f0c228403c6d02248b52 (patch)
tree2e8b1c8103727ae8a83d39dd59d4217430211de4 /dev/iphone_id.c
parentc57ebf917e30afd78dac8042552966811531c632 (diff)
downloadlibimobiledevice-d089bc54e88d7fa70be9f0c228403c6d02248b52.tar.gz
libimobiledevice-d089bc54e88d7fa70be9f0c228403c6d02248b52.tar.bz2
Move production ready tools into tools/ and do not install the dev/ ones
Diffstat (limited to 'dev/iphone_id.c')
-rw-r--r--dev/iphone_id.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/dev/iphone_id.c b/dev/iphone_id.c
deleted file mode 100644
index f68fc8b..0000000
--- a/dev/iphone_id.c
+++ /dev/null
@@ -1,94 +0,0 @@
1#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4#include <getopt.h>
5#include <libiphone/libiphone.h>
6#include <libiphone/lockdown.h>
7#include <usbmuxd.h>
8
9static void usage()
10{
11 printf("usage: iphone_id <device_uuid>\n"
12 "\tdevice_uuid is the 40-digit hexadecimal UUID of the device\n"
13 "\tfor which the name should be retrieved.\n\n"
14 "usage: iphone_id -l\n"
15 "\tList all attached devices.\n");
16 exit(0);
17}
18
19int main(int argc, char **argv)
20{
21 iphone_device_t phone = NULL;
22 lockdownd_client_t client = NULL;
23 usbmuxd_scan_result *dev_list;
24 char *devname = NULL;
25 int ret = 0;
26 int c;
27 int i;
28 int opt_list = 0;
29
30 while ((c = getopt(argc, argv, "lh")) != -1) {
31 switch (c) {
32 case 'l':
33 opt_list = 1;
34 break;
35 case 'h':
36 default:
37 usage();
38 }
39 }
40
41 if (argc < 2) {
42 usage();
43 }
44
45 argc -= optind;
46 argv += optind;
47
48 if ((!opt_list) && (strlen(argv[0]) != 40)) {
49 usage();
50 }
51
52 if (opt_list) {
53 if (usbmuxd_scan(&dev_list) < 0) {
54 fprintf(stderr, "ERROR: usbmuxd is not running!\n");
55 return -1;
56 }
57 for (i = 0; dev_list[i].handle > 0; i++) {
58 printf("handle=%d product_id=%04x uuid=%s\n", dev_list[i].handle, dev_list[i].product_id, dev_list[i].serial_number);
59 }
60 return 0;
61 }
62
63 iphone_set_debug_level(0);
64
65 iphone_get_device_by_uuid(&phone, argv[0]);
66 if (!phone) {
67 fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", argv[0]);
68 return -2;
69 }
70
71 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
72 iphone_device_free(phone);
73 fprintf(stderr, "ERROR: Connecting to device failed!\n");
74 return -2;
75 }
76
77 if ((LOCKDOWN_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) {
78 fprintf(stderr, "ERROR: Could not get device name!\n");
79 ret = -2;
80 }
81
82 lockdownd_client_free(client);
83 iphone_device_free(phone);
84
85 if (ret == 0) {
86 printf("%s\n", devname);
87 }
88
89 if (devname) {
90 free(devname);
91 }
92
93 return ret;
94}