summaryrefslogtreecommitdiff
path: root/src/libstddjb/allreadwritev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/allreadwritev.c')
-rw-r--r--src/libstddjb/allreadwritev.c21
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 ;
+}