diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-02-01 12:06:52 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-02-01 12:06:52 +0000 |
commit | ed49b72c0a31b6034026948851edf11cfa990fa0 (patch) | |
tree | ae33dbab4122f47187a72ef49834e107e316bdea /src | |
parent | 334d7f09d8dec83b9399e2cc44490b3868cd0772 (diff) | |
download | skalibs-ed49b72c0a31b6034026948851edf11cfa990fa0.tar.xz |
Add allreadwritev and friends
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/allreadwrite.h | 6 | ||||
-rw-r--r-- | src/include/skalibs/functypes.h | 8 | ||||
-rw-r--r-- | src/libstddjb/allreadwrite.c | 1 | ||||
-rw-r--r-- | src/libstddjb/buffer_write.c | 7 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h index 6b2a0cf..d2e6bf7 100644 --- a/src/include/skalibs/allreadwrite.h +++ b/src/include/skalibs/allreadwrite.h @@ -6,11 +6,13 @@ #include <sys/types.h> #include <sys/uio.h> #include <skalibs/functypes.h> +#include <skalibs/siovec.h> extern int sanitize_read (int) ; extern int unsanitize_read (int) ; extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ; +extern unsigned int allreadwritev (iovfunc_t_ref, int, siovec_t const *, unsigned int) ; extern int fd_read (int, char *, unsigned int) ; extern int fd_write (int, char const *, unsigned int) ; @@ -20,8 +22,12 @@ extern int fd_send (int, char const *, unsigned int, unsigned int) ; extern unsigned int allread (int, char *, unsigned int) ; extern unsigned int allwrite (int, char const *, unsigned int) ; +extern unsigned int allreadv (int, siovec_t const *, unsigned int) ; +extern unsigned int allwritev (int, siovec_t const *, unsigned int) ; extern int fd_readv (int, struct iovec const *, unsigned int) ; +extern int fd_readsv (int, siovec_t const *, unsigned int) ; extern int fd_writev (int, struct iovec const *, unsigned int) ; +extern int fd_writesv (int, siovec_t const *, unsigned int) ; #endif diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h index 15cdbcc..d7094fc 100644 --- a/src/include/skalibs/functypes.h +++ b/src/include/skalibs/functypes.h @@ -3,6 +3,8 @@ #ifndef FUNCTYPES_H #define FUNCTYPES_H +#include <skalibs/siovec.h> + typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ; typedef uintcmpfunc_t *uintcmpfunc_t_ref ; @@ -27,7 +29,13 @@ typedef uinitfunc_t *uinitfunc_t_ref ; typedef int iofunc_t (int, char *, unsigned int) ; typedef iofunc_t *iofunc_t_ref ; +typedef int iovfunc_t (int, siovec_t const *, unsigned int) ; +typedef iovfunc_t *iovfunc_t_ref ; + typedef unsigned int alliofunc_t (int, char *, unsigned int) ; typedef alliofunc_t *alliofunc_t_ref ; +typedef unsigned int alliovfunc_t (int, siovec_t const *, unsigned int) ; +typedef alliovfunc_t *alliovfunc_t_ref ; + #endif diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c index 7e7867b..c15f6de 100644 --- a/src/libstddjb/allreadwrite.c +++ b/src/libstddjb/allreadwrite.c @@ -9,7 +9,6 @@ unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register while (len) { register int w = (*op)(fd, buf, len) ; - if (!w) errno = EPIPE ; if (w <= 0) break ; written += w ; buf += w ; diff --git a/src/libstddjb/buffer_write.c b/src/libstddjb/buffer_write.c index e669f60..b924cbb 100644 --- a/src/libstddjb/buffer_write.c +++ b/src/libstddjb/buffer_write.c @@ -1,14 +1,11 @@ /* ISC license. */ -#include <sys/types.h> -#include <sys/uio.h> #include <skalibs/allreadwrite.h> #include <skalibs/siovec.h> #include <skalibs/buffer.h> int buffer_write (int fd, siovec_t const *v, unsigned int n) { - struct iovec iov[n] ; - iovec_from_siovec(iov, v, n) ; - return fd_writev(fd, iov, n) ; + unsigned int w = allreadwritev(&fd_writesv, fd, v, n) ; + return w ? (int)w : -1 ; } |