From c153ee92a1036cdec929d3d04b396373e5011a1c Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 8 Apr 2012 01:16:07 +0200 Subject: idevicesyslog: fix reading from syslog_relay (simple socket connection) --- tools/idevicesyslog.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'tools') 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); -- cgit v1.1-32-gdbae