#elif defined(SENDFILE_FLAVOR_BSD )
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/uio.h><
+#include <sys/uio.h>
ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
{
- return sendfile(fromfd, tofd, *offset, count, NULL, offset, 0);
+ off_t len;
+ int ret;
+
+ ret = sendfile(fromfd, tofd, *offset, count, NULL, &len, 0);
+
+ *offset += len;
+
+ if (ret != 0)
+ return -1;
+ return len;
}
#else
return fd;
}
-
-
-/* ------------------------ */
-#if 0
-#ifdef HAVE_SENDFILE_WRITE
-/* read from a socket and write to an adouble file */
-ssize_t ad_writefile(struct adouble *ad, const int eid,
- const int sock, off_t off, const int end,
- const size_t len)
-{
-#ifdef __linux__
- ssize_t cc;
- int fd;
-
- fd = ad_sendfile_init(ad, eid, &off, end);
- if ((cc = sys_sendfile(fd, sock, &off, len)) < 0)
- return -1;
-
- if ((eid != ADEID_DFORK) && (off > ad_getentrylen(ad, eid)))
- ad_setentrylen(ad, eid, off);
-
- return cc;
-#endif /* __linux__ */
-}
-#endif /* HAVE_SENDFILE_WRITE */
-#endif /* 0 */
#endif