7 /* determine amount of data ready to read
9 /* #include <iostuff.h>
14 /* peekfd() attempts to find out how many bytes are available to
15 /* be read from the named file descriptor. The result value is
16 /* the number of available bytes.
18 /* peekfd() returns -1 in case of trouble. The global \fIerrno\fR
19 /* variable reflects the nature of the problem.
21 /* On some systems, non-blocking read() may fail even after a
22 /* positive return from peekfd(). The smtp-sink program works
23 /* around this by using the readable() function instead.
27 /* The Secure Mailer license must be distributed with this software.
30 /* IBM T.J. Watson Research
32 /* Yorktown Heights, NY 10598, USA
38 #include <sys/ioctl.h>
39 #ifdef FIONREAD_IN_SYS_FILIO_H
40 #include <sys/filio.h>
42 #ifdef FIONREAD_IN_TERMIOS_H
47 /* Utility library. */
51 /* peekfd - return amount of data ready to read */
53 ssize_t
peekfd(int fd
)
57 * Anticipate a series of system-dependent code fragments.
62 return (ioctl(fd
, FIONREAD
, (char *) &count
) < 0 ? -1 : count
);
64 #error "don't know how to look ahead"