diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2000-04-24 15:32:11 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2000-04-24 15:32:11 +0200 |
commit | ba70704694e879246856d6bb98be3e3d01ab0156 (patch) | |
tree | 048e718409a1cec97c8ca01828920a962e28acfa /tools.c | |
parent | 8a84f6b751f54b71f2476beef2eec10a9c919f36 (diff) | |
download | vdr-ba70704694e879246856d6bb98be3e3d01ab0156.tar.gz vdr-ba70704694e879246856d6bb98be3e3d01ab0156.tar.bz2 |
Improved replay progress display
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.6 2000/04/24 13:54:23 kls Exp $ + * $Id: tools.c 1.7 2000/04/24 15:01:35 kls Exp $ */ #define _GNU_SOURCE @@ -22,6 +22,17 @@ int SysLogLevel = 3; +bool DataAvailable(int filedes) +{ + fd_set set; + FD_ZERO(&set); + FD_SET(filedes, &set); + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(filedes, &set); +} + void writechar(int filedes, char c) { write(filedes, &c, sizeof(c)); @@ -41,7 +52,13 @@ char readchar(int filedes) bool readint(int filedes, int &n) { - return read(filedes, &n, sizeof(n)) == sizeof(n); + return DataAvailable(filedes) && read(filedes, &n, sizeof(n)) == sizeof(n); +} + +void purge(int filedes) +{ + while (DataAvailable(filedes)) + readchar(filedes); } char *readline(FILE *f) |