summaryrefslogtreecommitdiff
path: root/imap4d
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-01-28 21:44:46 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-01-28 21:44:46 +0000
commit02e2dd1ab23ef3e50512fcb7c5d889132ca672e0 (patch)
tree03c37261ce1cdf1fe6c1ce4e9eb36304233e2cbb /imap4d
parent3b3e96afa32e4555b99372e3dbaffd7faf4da5cc (diff)
downloadmailutils-02e2dd1ab23ef3e50512fcb7c5d889132ca672e0.tar.gz
mailutils-02e2dd1ab23ef3e50512fcb7c5d889132ca672e0.tar.bz2
(util_wait_input): New function.
Diffstat (limited to 'imap4d')
-rw-r--r--imap4d/util.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/imap4d/util.c b/imap4d/util.c
index f0e682b3e..5d9b0d9b0 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -1125,6 +1125,39 @@ util_set_output (stream_t str)
ostream = str;
}
+/* Wait TIMEOUT seconds for data on the input stream.
+ Returns 0 if no data available
+ 1 if some data is available
+ -1 an error occurred */
+int
+util_wait_input (int timeout)
+{
+ int rc, fd;
+ fd_set rdset;
+
+ if (stream_get_fd (istream, &fd))
+ {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ FD_ZERO (&rdset);
+ FD_SET (fd, &rdset);
+
+ do
+ {
+ struct timeval tv;
+
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+
+ rc = select (fd + 1, &rdset, NULL, NULL, &tv);
+ }
+ while (rc == -1 && errno == EINTR);
+
+ return rc;
+}
+
void
util_flush_output ()
{

Return to:

Send suggestions and report system problems to the System administrator.