dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
AC_CHECK_FUNCS(fcntl flock inet_aton sigaction getpagesize madvise \
- strcasecmp stricmp vsnprintf vsyslog writev setrlimit \
- setproctitle)
+ strcasecmp stricmp vsnprintf vsyslog writev pwrite \
+ setrlimit setproctitle)
dnl * poll/select?
return (ssize_t)written;
}
#endif
+
+#ifndef HAVE_PWRITE
+ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+{
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ return -1;
+ return read(fd, buf, count);
+}
+
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ return -1;
+ return write(fd, buf, count);
+}
+#endif
ssize_t my_writev(int fd, const struct iovec *iov, int iov_len);
#endif
+#ifndef HAVE_PWRITE
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+#endif
+
/* ctype.h isn't safe with signed chars,
use our own instead if really needed */
#define i_toupper(x) ((char) toupper((int) (unsigned char) (x)))