diff options
| author | 2009-09-10 13:28:13 +0200 | |
|---|---|---|
| committer | 2009-09-12 11:41:38 +0200 | |
| commit | 1f6282ffddec7012df82fa929dfe72cfc74b063a (patch) | |
| tree | 452c927c07806855f360ee9803111a1f72e05d3c /tools | |
| parent | 26ce10634d277df51c4e9c2bd61b409df3f5b060 (diff) | |
| download | libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.gz libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.bz2 | |
Public API rework, extension and adaption to latest libusbmuxd-1.0 API.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/iphone_id.c | 9 | ||||
| -rw-r--r-- | tools/iphoneinfo.c | 4 | ||||
| -rw-r--r-- | tools/iphonesyslog.c | 16 |
3 files changed, 14 insertions, 15 deletions
diff --git a/tools/iphone_id.c b/tools/iphone_id.c index 835e214..ab36e7c 100644 --- a/tools/iphone_id.c +++ b/tools/iphone_id.c | |||
| @@ -28,7 +28,7 @@ int main(int argc, char **argv) | |||
| 28 | { | 28 | { |
| 29 | iphone_device_t phone = NULL; | 29 | iphone_device_t phone = NULL; |
| 30 | lockdownd_client_t client = NULL; | 30 | lockdownd_client_t client = NULL; |
| 31 | usbmuxd_scan_result *dev_list; | 31 | usbmuxd_device_info_t *dev_list; |
| 32 | char *devname = NULL; | 32 | char *devname = NULL; |
| 33 | int ret = 0; | 33 | int ret = 0; |
| 34 | int i; | 34 | int i; |
| @@ -65,7 +65,7 @@ int main(int argc, char **argv) | |||
| 65 | 65 | ||
| 66 | switch (mode) { | 66 | switch (mode) { |
| 67 | case MODE_SHOW_ID: | 67 | case MODE_SHOW_ID: |
| 68 | iphone_get_device_by_uuid(&phone, uuid); | 68 | iphone_device_new(&phone, uuid); |
| 69 | if (!phone) { | 69 | if (!phone) { |
| 70 | fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", uuid); | 70 | fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", uuid); |
| 71 | return -2; | 71 | return -2; |
| @@ -96,13 +96,14 @@ int main(int argc, char **argv) | |||
| 96 | return ret; | 96 | return ret; |
| 97 | case MODE_LIST_DEVICES: | 97 | case MODE_LIST_DEVICES: |
| 98 | default: | 98 | default: |
| 99 | if (usbmuxd_scan(&dev_list) < 0) { | 99 | if (usbmuxd_get_device_list(&dev_list) < 0) { |
| 100 | fprintf(stderr, "ERROR: usbmuxd is not running!\n"); | 100 | fprintf(stderr, "ERROR: usbmuxd is not running!\n"); |
| 101 | return -1; | 101 | return -1; |
| 102 | } | 102 | } |
| 103 | for (i = 0; dev_list[i].handle > 0; i++) { | 103 | for (i = 0; dev_list[i].handle > 0; i++) { |
| 104 | printf("handle=%d product_id=%04x uuid=%s\n", dev_list[i].handle, dev_list[i].product_id, dev_list[i].serial_number); | 104 | printf("handle=%d product_id=%04x uuid=%s\n", dev_list[i].handle, dev_list[i].product_id, dev_list[i].uuid); |
| 105 | } | 105 | } |
| 106 | usbmuxd_free_device_list(dev_list); | ||
| 106 | return 0; | 107 | return 0; |
| 107 | } | 108 | } |
| 108 | } | 109 | } |
diff --git a/tools/iphoneinfo.c b/tools/iphoneinfo.c index 7e275b2..16a1069 100644 --- a/tools/iphoneinfo.c +++ b/tools/iphoneinfo.c | |||
| @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | if (uuid[0] != 0) { | 123 | if (uuid[0] != 0) { |
| 124 | ret = iphone_get_device_by_uuid(&phone, uuid); | 124 | ret = iphone_device_new(&phone, uuid); |
| 125 | if (ret != IPHONE_E_SUCCESS) { | 125 | if (ret != IPHONE_E_SUCCESS) { |
| 126 | printf("No device found with uuid %s, is it plugged in?\n", uuid); | 126 | printf("No device found with uuid %s, is it plugged in?\n", uuid); |
| 127 | return -1; | 127 | return -1; |
| @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) | |||
| 129 | } | 129 | } |
| 130 | else | 130 | else |
| 131 | { | 131 | { |
| 132 | ret = iphone_get_device(&phone); | 132 | ret = iphone_device_new(&phone, NULL); |
| 133 | if (ret != IPHONE_E_SUCCESS) { | 133 | if (ret != IPHONE_E_SUCCESS) { |
| 134 | printf("No device found, is it plugged in?\n"); | 134 | printf("No device found, is it plugged in?\n"); |
| 135 | return -1; | 135 | return -1; |
diff --git a/tools/iphonesyslog.c b/tools/iphonesyslog.c index a096101..10b3fb6 100644 --- a/tools/iphonesyslog.c +++ b/tools/iphonesyslog.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | #include <libiphone/libiphone.h> | 29 | #include <libiphone/libiphone.h> |
| 30 | #include <libiphone/lockdown.h> | 30 | #include <libiphone/lockdown.h> |
| 31 | #include <usbmuxd.h> | ||
| 32 | 31 | ||
| 33 | static int quit_flag = 0; | 32 | static int quit_flag = 0; |
| 34 | 33 | ||
| @@ -86,7 +85,7 @@ int main(int argc, char *argv[]) | |||
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | if (uuid[0] != 0) { | 87 | if (uuid[0] != 0) { |
| 89 | ret = iphone_get_device_by_uuid(&phone, uuid); | 88 | ret = iphone_device_new(&phone, uuid); |
| 90 | if (ret != IPHONE_E_SUCCESS) { | 89 | if (ret != IPHONE_E_SUCCESS) { |
| 91 | printf("No device found with uuid %s, is it plugged in?\n", uuid); | 90 | printf("No device found with uuid %s, is it plugged in?\n", uuid); |
| 92 | return -1; | 91 | return -1; |
| @@ -94,7 +93,7 @@ int main(int argc, char *argv[]) | |||
| 94 | } | 93 | } |
| 95 | else | 94 | else |
| 96 | { | 95 | { |
| 97 | ret = iphone_get_device(&phone); | 96 | ret = iphone_device_new(&phone, NULL); |
| 98 | if (ret != IPHONE_E_SUCCESS) { | 97 | if (ret != IPHONE_E_SUCCESS) { |
| 99 | printf("No device found, is it plugged in?\n"); | 98 | printf("No device found, is it plugged in?\n"); |
| 100 | return -1; | 99 | return -1; |
| @@ -112,16 +111,15 @@ int main(int argc, char *argv[]) | |||
| 112 | lockdownd_client_free(client); | 111 | lockdownd_client_free(client); |
| 113 | 112 | ||
| 114 | /* connect to socket relay messages */ | 113 | /* connect to socket relay messages */ |
| 115 | iphone_device_get_handle(phone, &handle); | 114 | iphone_connection_t conn = NULL; |
| 116 | int sfd = usbmuxd_connect(handle, port); | 115 | if ((iphone_device_connect(phone, port, &conn) != IPHONE_E_SUCCESS) || !conn) { |
| 117 | if (sfd < 0) { | ||
| 118 | printf("ERROR: Could not open usbmux connection.\n"); | 116 | printf("ERROR: Could not open usbmux connection.\n"); |
| 119 | } else { | 117 | } else { |
| 120 | while (!quit_flag) { | 118 | while (!quit_flag) { |
| 121 | char *receive = NULL; | 119 | char *receive = NULL; |
| 122 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; | 120 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; |
| 123 | 121 | ||
| 124 | ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); | 122 | ret = iphone_device_recv(conn, (char *) &datalen, sizeof(datalen), &bytes); |
| 125 | datalen = ntohl(datalen); | 123 | datalen = ntohl(datalen); |
| 126 | 124 | ||
| 127 | if (datalen == 0) | 125 | if (datalen == 0) |
| @@ -131,7 +129,7 @@ int main(int argc, char *argv[]) | |||
| 131 | receive = (char *) malloc(sizeof(char) * datalen); | 129 | receive = (char *) malloc(sizeof(char) * datalen); |
| 132 | 130 | ||
| 133 | while (!quit_flag && (recv_bytes <= datalen)) { | 131 | while (!quit_flag && (recv_bytes <= datalen)) { |
| 134 | ret = usbmuxd_recv(sfd, receive, datalen, &bytes); | 132 | ret = iphone_device_recv(conn, receive, datalen, &bytes); |
| 135 | 133 | ||
| 136 | if (bytes == 0) | 134 | if (bytes == 0) |
| 137 | break; | 135 | break; |
| @@ -144,7 +142,7 @@ int main(int argc, char *argv[]) | |||
| 144 | free(receive); | 142 | free(receive); |
| 145 | } | 143 | } |
| 146 | } | 144 | } |
| 147 | usbmuxd_disconnect(sfd); | 145 | iphone_device_disconnect(conn); |
| 148 | } else { | 146 | } else { |
| 149 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); | 147 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); |
| 150 | } | 148 | } |
