diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicesyslog.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index 393c88e..227bf3d 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c | |||
| @@ -116,36 +116,16 @@ int main(int argc, char *argv[]) | |||
| 116 | printf("ERROR: Could not open usbmux connection.\n"); | 116 | printf("ERROR: Could not open usbmux connection.\n"); |
| 117 | } else { | 117 | } else { |
| 118 | while (!quit_flag) { | 118 | while (!quit_flag) { |
| 119 | char *receive = NULL; | 119 | char c; |
| 120 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; | 120 | uint32_t bytes = 0; |
| 121 | 121 | if ((idevice_connection_receive(conn, &c, 1, &bytes) < 0) || (bytes != 1)) { | |
| 122 | ret = idevice_connection_receive(conn, (char *) &datalen, sizeof(datalen), &bytes); | ||
| 123 | if (ret < 0) { | ||
| 124 | fprintf(stderr, "Error receiving data. Exiting...\n"); | 122 | fprintf(stderr, "Error receiving data. Exiting...\n"); |
| 125 | break; | 123 | break; |
| 126 | } | 124 | } |
| 127 | 125 | if (c != 0) { | |
| 128 | datalen = be32toh(datalen); | 126 | putchar(c); |
| 129 | |||
| 130 | if (datalen == 0) | ||
| 131 | continue; | ||
| 132 | |||
| 133 | recv_bytes += bytes; | ||
| 134 | receive = (char *) malloc(sizeof(char) * datalen); | ||
| 135 | |||
| 136 | while (!quit_flag && (recv_bytes <= datalen)) { | ||
| 137 | ret = idevice_connection_receive(conn, receive, datalen, &bytes); | ||
| 138 | |||
| 139 | if (bytes == 0) | ||
| 140 | break; | ||
| 141 | |||
| 142 | recv_bytes += bytes; | ||
| 143 | |||
| 144 | fwrite(receive, sizeof(char), bytes, stdout); | ||
| 145 | fflush(stdout); | 127 | fflush(stdout); |
| 146 | } | 128 | } |
| 147 | |||
| 148 | free(receive); | ||
| 149 | } | 129 | } |
| 150 | } | 130 | } |
| 151 | idevice_disconnect(conn); | 131 | idevice_disconnect(conn); |
