diff options
author | Nikias Bassen | 2012-04-08 01:16:07 +0200 |
---|---|---|
committer | Nikias Bassen | 2012-04-08 01:16:07 +0200 |
commit | c153ee92a1036cdec929d3d04b396373e5011a1c (patch) | |
tree | dd05e8ff566b955baac38261e5d611cac1d287a9 /tools | |
parent | a902a9a24f64b295336af35a53a6f0a574fd89c2 (diff) | |
download | libimobiledevice-c153ee92a1036cdec929d3d04b396373e5011a1c.tar.gz libimobiledevice-c153ee92a1036cdec929d3d04b396373e5011a1c.tar.bz2 |
idevicesyslog: fix reading from syslog_relay (simple socket connection)
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[]) printf("ERROR: Could not open usbmux connection.\n"); } else { while (!quit_flag) { - char *receive = NULL; - uint32_t datalen = 0, bytes = 0, recv_bytes = 0; - - ret = idevice_connection_receive(conn, (char *) &datalen, sizeof(datalen), &bytes); - if (ret < 0) { + char c; + uint32_t bytes = 0; + if ((idevice_connection_receive(conn, &c, 1, &bytes) < 0) || (bytes != 1)) { fprintf(stderr, "Error receiving data. Exiting...\n"); break; } - - datalen = be32toh(datalen); - - if (datalen == 0) - continue; - - recv_bytes += bytes; - receive = (char *) malloc(sizeof(char) * datalen); - - while (!quit_flag && (recv_bytes <= datalen)) { - ret = idevice_connection_receive(conn, receive, datalen, &bytes); - - if (bytes == 0) - break; - - recv_bytes += bytes; - - fwrite(receive, sizeof(char), bytes, stdout); + if (c != 0) { + putchar(c); fflush(stdout); } - - free(receive); } } idevice_disconnect(conn); |