Commit d88a7406 authored by Niels Möller's avatar Niels Möller

* src/io.c (io_readable_p): New function, replacing the static

function readable_p in service_read.c and transport_read.c.

Rev: src/io.c:1.219
Rev: src/io.h:1.113
parent 14ec89fc
......@@ -41,6 +41,12 @@
#include <sys/un.h>
/* For the popen code */
#include <sys/wait.h>
#include <sys/ioctl.h>
/* Needed for FIONREAD on Solaris */
#if HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#include <arpa/inet.h>
......@@ -533,6 +539,22 @@ io_read_file_raw(int fd, uint32_t guess)
}
}
int
io_readable_p(int fd)
{
#if HAVE_IOCTL_FIONREAD
int nbytes = 0;
if (ioctl(fd, FIONREAD, &nbytes) < 0)
{
debug("ioctl FIONREAD failed: %e\n", errno);
return 0;
}
return nbytes != 0;
#else /* ! HAVE_IOCTL_FIONREAD */
return 0;
#endif /* !HAVE_IOCTL_FIONREAD */
}
/* Network utility functions */
/* Converts a string port number or service name to a port number.
......
......@@ -153,6 +153,9 @@ write_raw(int fd, uint32_t length, const uint8_t *data);
struct lsh_string *
io_read_file_raw(int fd, uint32_t guess);
int
io_readable_p(int fd);
void io_set_nonblocking(int fd);
void io_set_blocking(int fd);
void io_set_close_on_exec(int fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment