summaryrefslogtreecommitdiffstats
path: root/tools/idevicesyslog.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-04-08 01:16:07 +0200
committerGravatar Nikias Bassen2012-04-08 01:16:07 +0200
commitc153ee92a1036cdec929d3d04b396373e5011a1c (patch)
treedd05e8ff566b955baac38261e5d611cac1d287a9 /tools/idevicesyslog.c
parenta902a9a24f64b295336af35a53a6f0a574fd89c2 (diff)
downloadlibimobiledevice-c153ee92a1036cdec929d3d04b396373e5011a1c.tar.gz
libimobiledevice-c153ee92a1036cdec929d3d04b396373e5011a1c.tar.bz2
idevicesyslog: fix reading from syslog_relay (simple socket connection)
Diffstat (limited to 'tools/idevicesyslog.c')
-rw-r--r--tools/idevicesyslog.c30
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);