X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=blobdiff_plain;f=io.c;fp=io.c;h=6e9dde76808518e4abd6c1adcc3134ccb9b529c9;hp=478f731d8a6ee1c40ce3663a73741b8db041a7df;hb=de010509fa0e57ba955da6512c714fbff8606af3;hpb=60900035e6d0309705f2326ee50edc52386305e9 diff --git a/io.c b/io.c index 478f731..6e9dde7 100644 --- a/io.c +++ b/io.c @@ -11,6 +11,7 @@ #include #include +#include #include #include "io.h" @@ -63,6 +64,27 @@ void io_init(io_t * io) { ASSERT(io_is_ok(io)); } +// io_peek() + +bool io_peek(io_t * io){ + fd_set set[1]; + int fd_max; + int ret; + struct timeval tv; + tv.tv_sec=0; + tv.tv_usec=0; + + FD_ZERO(set); + FD_SET(io->in_fd,set); + fd_max=io->in_fd; + ret=select(fd_max+1,set,NULL,NULL,&tv); + if(ret>0){ + return TRUE; + }else{ + return FALSE; + } +} + // io_close() void io_close(io_t * io) {