From cea441e894405c6d28e302ae4360e9f848b37797 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 1 Feb 2015 13:50:13 +0000 Subject: It will work better with the new files >.> --- src/libstddjb/allreadv.c | 9 +++++++++ src/libstddjb/allreadwritev.c | 21 +++++++++++++++++++++ src/libstddjb/allwritev.c | 9 +++++++++ src/libstddjb/fd_readsv.c | 11 +++++++++++ src/libstddjb/fd_writesv.c | 11 +++++++++++ 5 files changed, 61 insertions(+) create mode 100644 src/libstddjb/allreadv.c create mode 100644 src/libstddjb/allreadwritev.c create mode 100644 src/libstddjb/allwritev.c create mode 100644 src/libstddjb/fd_readsv.c create mode 100644 src/libstddjb/fd_writesv.c diff --git a/src/libstddjb/allreadv.c b/src/libstddjb/allreadv.c new file mode 100644 index 0000000..5eb3863 --- /dev/null +++ b/src/libstddjb/allreadv.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include +#include + +unsigned int allreadv (int fd, siovec_t const *v, unsigned int vlen) +{ + return allreadwritev(&fd_readsv, fd, v, vlen) ; +} diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c new file mode 100644 index 0000000..a156698 --- /dev/null +++ b/src/libstddjb/allreadwritev.c @@ -0,0 +1,21 @@ +/* ISC license. */ + +#include +#include +#include + +unsigned int allreadwritev (iovfunc_t_ref op, int fd, siovec_t const *v, unsigned int vlen) +{ + register unsigned int written = 0 ; + siovec_t vv[vlen] ; + for (; written < vlen ; written++) vv[written] = v[written] ; + written = 0 ; + while (siovec_len(v, vlen)) + { + register int w = (*op)(fd, vv, vlen) ; + if (w <= 0) break ; + w = siovec_seek(vv, vlen, w) ; + written += w ; + } + return written ; +} diff --git a/src/libstddjb/allwritev.c b/src/libstddjb/allwritev.c new file mode 100644 index 0000000..d7195a8 --- /dev/null +++ b/src/libstddjb/allwritev.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include +#include + +unsigned int allwritev (int fd, siovec_t const *v, unsigned int vlen) +{ + return allreadwritev(&fd_writesv, fd, v, vlen) ; +} diff --git a/src/libstddjb/fd_readsv.c b/src/libstddjb/fd_readsv.c new file mode 100644 index 0000000..39efe19 --- /dev/null +++ b/src/libstddjb/fd_readsv.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include +#include + +int fd_readsv (int fd, siovec_t const *v, unsigned int vlen) +{ + struct iovec vv[vlen] ; + iovec_from_siovec(vv, v, vlen) ; + return fd_readv(fd, vv, vlen) ; +} diff --git a/src/libstddjb/fd_writesv.c b/src/libstddjb/fd_writesv.c new file mode 100644 index 0000000..bd3c2c3 --- /dev/null +++ b/src/libstddjb/fd_writesv.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include +#include + +int fd_writesv (int fd, siovec_t const *v, unsigned int vlen) +{ + struct iovec vv[vlen] ; + iovec_from_siovec(vv, v, vlen) ; + return fd_writev(fd, vv, vlen) ; +} -- cgit v1.2.3