* Known contributors to this file:
* Doug Hay, 1998
* Steve McClure, 1998
- * Markus Armbruster, 2004-2010
+ * Markus Armbruster, 2004-2012
* Ron Koenderink, 2009
*/
int cc;
int res;
- /* Not a read IOP */
if ((iop->flags & IO_READ) == 0) {
errno = EBADF;
return -1;
}
- /* IOP is markes as in error. */
if (iop->flags & IO_ERROR) {
errno = EBADF;
return -1;
}
+ if (iop->flags & IO_EOF)
+ return 0;
+
/* Wait for the file to have input. */
if (waitforinput) {
res = empth_select(iop->fd, EMPTH_FD_READ, &iop->input_timeout);
return io_output(iop, wait);
}
-
int
io_peek(struct iop *iop, char *buf, int nbytes)
{
return iop->flags & IO_EOF;
}
+/*
+ * Discard IOP's buffered input and set its EOF flag.
+ * No more input can be read from IOP.
+ */
+void
+io_set_eof(struct iop *iop)
+{
+ ioq_drain(iop->input);
+ iop->flags |= IO_EOF;
+}
+
int
io_fileno(struct iop *iop)
{