summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2000-04-24 15:32:11 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2000-04-24 15:32:11 +0200
commitba70704694e879246856d6bb98be3e3d01ab0156 (patch)
tree048e718409a1cec97c8ca01828920a962e28acfa /tools.c
parent8a84f6b751f54b71f2476beef2eec10a9c919f36 (diff)
downloadvdr-ba70704694e879246856d6bb98be3e3d01ab0156.tar.gz
vdr-ba70704694e879246856d6bb98be3e3d01ab0156.tar.bz2
Improved replay progress display
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools.c b/tools.c
index c43e610f..eb0a14a4 100644
--- a/tools.c
+++ b/tools.c
@@ -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)