diff options
| author | 2009-05-18 22:29:39 +0200 | |
|---|---|---|
| committer | 2009-05-18 18:47:20 -0700 | |
| commit | 8eaac0513bfb238edec22d46320669f5c9c76542 (patch) | |
| tree | 2db842339bf525d67017525bcbd3f4d35181e5ca /dev/syslog_relay.c | |
| parent | dca1758c4f9602fc240c6a7c9ae45839e154d15f (diff) | |
| download | libimobiledevice-8eaac0513bfb238edec22d46320669f5c9c76542.tar.gz libimobiledevice-8eaac0513bfb238edec22d46320669f5c9c76542.tar.bz2 | |
Make use of usbmuxd and remove libusb dependencies
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'dev/syslog_relay.c')
| -rw-r--r-- | dev/syslog_relay.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 56cf56c..35c684a 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <usb.h> | 27 | #include <usb.h> |
| 28 | 28 | ||
| 29 | #include <libiphone/libiphone.h> | 29 | #include <libiphone/libiphone.h> |
| 30 | #include <usbmuxd.h> | ||
| 30 | 31 | ||
| 31 | static int quit_flag = 0; | 32 | static int quit_flag = 0; |
| 32 | 33 | ||
| @@ -78,7 +79,7 @@ int main(int argc, char *argv[]) | |||
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | if (bus_n != -1) { | 82 | /* if (bus_n != -1) { |
| 82 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); | 83 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); |
| 83 | if (ret != IPHONE_E_SUCCESS) { | 84 | if (ret != IPHONE_E_SUCCESS) { |
| 84 | printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); | 85 | printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); |
| @@ -86,13 +87,13 @@ int main(int argc, char *argv[]) | |||
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | else | 89 | else |
| 89 | { | 90 | {*/ |
| 90 | ret = iphone_get_device(&phone); | 91 | ret = iphone_get_device(&phone); |
| 91 | if (ret != IPHONE_E_SUCCESS) { | 92 | if (ret != IPHONE_E_SUCCESS) { |
| 92 | printf("No device found, is it plugged in?\n"); | 93 | printf("No device found, is it plugged in?\n"); |
| 93 | return -1; | 94 | return -1; |
| 94 | } | 95 | } |
| 95 | } | 96 | /* }*/ |
| 96 | 97 | ||
| 97 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | 98 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { |
| 98 | iphone_free_device(phone); | 99 | iphone_free_device(phone); |
| @@ -103,15 +104,19 @@ int main(int argc, char *argv[]) | |||
| 103 | ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); | 104 | ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); |
| 104 | if ((ret == IPHONE_E_SUCCESS) && port) { | 105 | if ((ret == IPHONE_E_SUCCESS) && port) { |
| 105 | /* connect to socket relay messages */ | 106 | /* connect to socket relay messages */ |
| 106 | iphone_umux_client_t syslog_client = NULL; | 107 | //iphone_umux_client_t syslog_client = NULL; |
| 107 | 108 | ||
| 108 | ret = iphone_mux_new_client(phone, 514, port, &syslog_client); | 109 | //ret = iphone_mux_new_client(phone, 514, port, &syslog_client); |
| 109 | if (ret == IPHONE_E_SUCCESS) { | 110 | int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); |
| 111 | //if (ret == IPHONE_E_SUCCESS) { | ||
| 112 | if (sfd < 0) { | ||
| 113 | printf("ERROR: Could not open usbmux connection.\n"); | ||
| 114 | } else { | ||
| 110 | while (!quit_flag) { | 115 | while (!quit_flag) { |
| 111 | char *receive = NULL; | 116 | char *receive = NULL; |
| 112 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; | 117 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; |
| 113 | 118 | ||
| 114 | ret = iphone_mux_recv(syslog_client, (char *) &datalen, sizeof(datalen), &bytes); | 119 | ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); |
| 115 | datalen = ntohl(datalen); | 120 | datalen = ntohl(datalen); |
| 116 | 121 | ||
| 117 | if (datalen == 0) | 122 | if (datalen == 0) |
| @@ -121,7 +126,7 @@ int main(int argc, char *argv[]) | |||
| 121 | receive = (char *) malloc(sizeof(char) * datalen); | 126 | receive = (char *) malloc(sizeof(char) * datalen); |
| 122 | 127 | ||
| 123 | while (!quit_flag && (recv_bytes <= datalen)) { | 128 | while (!quit_flag && (recv_bytes <= datalen)) { |
| 124 | ret = iphone_mux_recv(syslog_client, receive, datalen, &bytes); | 129 | ret = usbmuxd_recv(sfd, receive, datalen, &bytes); |
| 125 | 130 | ||
| 126 | if (bytes == 0) | 131 | if (bytes == 0) |
| 127 | break; | 132 | break; |
| @@ -133,10 +138,8 @@ int main(int argc, char *argv[]) | |||
| 133 | 138 | ||
| 134 | free(receive); | 139 | free(receive); |
| 135 | } | 140 | } |
| 136 | } else { | ||
| 137 | printf("ERROR: Could not open usbmux connection.\n"); | ||
| 138 | } | 141 | } |
| 139 | iphone_mux_free_client(syslog_client); | 142 | usbmuxd_disconnect(sfd); //iphone_mux_free_client(syslog_client); |
| 140 | } else { | 143 | } else { |
| 141 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); | 144 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); |
| 142 | } | 145 | } |
