diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-02-01 13:50:13 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-02-01 13:50:13 +0000 |
commit | cea441e894405c6d28e302ae4360e9f848b37797 (patch) | |
tree | 497feb0ad176f9e07e3950628cdd99afa3ae9d8b /src/libstddjb/allreadwritev.c | |
parent | ed49b72c0a31b6034026948851edf11cfa990fa0 (diff) | |
download | skalibs-cea441e894405c6d28e302ae4360e9f848b37797.tar.xz |
It will work better with the new files >.>
Diffstat (limited to 'src/libstddjb/allreadwritev.c')
-rw-r--r-- | src/libstddjb/allreadwritev.c | 21 |
1 files changed, 21 insertions, 0 deletions
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 <errno.h> +#include <skalibs/allreadwrite.h> +#include <skalibs/siovec.h> + +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 ; +} |