summaryrefslogtreecommitdiff
path: root/src/libstddjb/buffer_getvall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/buffer_getvall.c')
-rw-r--r--src/libstddjb/buffer_getvall.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/libstddjb/buffer_getvall.c b/src/libstddjb/buffer_getvall.c
index b6eeb46..e34c547 100644
--- a/src/libstddjb/buffer_getvall.c
+++ b/src/libstddjb/buffer_getvall.c
@@ -1,18 +1,30 @@
/* ISC license. */
#include <errno.h>
+#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
-#include <skalibs/diuint.h>
#include <skalibs/siovec.h>
-int buffer_getvall (buffer *b, siovec_t const *v, unsigned int n, diuint *w)
+int buffer_getvall (buffer *b, siovec_t const *v, unsigned int n, unsigned int *written)
{
- if (w->left > n || (w->left == n && w->right) || w->right >= v[w->left].len)
- return (errno = EINVAL, -1) ;
- for (; w->left < n ; w->left++, w->right = 0)
+ unsigned int len = siovec_len(v, n) ;
+ siovec_t vv[n] ;
+ if (*written > len) return (errno = EINVAL, -1) ;
{
- register int r = buffer_getall(b, v[w->left].s, v[w->left].len, &w->right) ;
+ register unsigned int i = n ;
+ while (i--) vv[i] = v[i] ;
+ }
+ siovec_seek(vv, n, *written) ;
+ for (;;)
+ {
+ register int r ;
+ unsigned int w = buffer_getvnofill(b, vv, n) ;
+ *written += w ;
+ if (*written >= len) break ;
+ siovec_seek(vv, n, w) ;
+ r = sanitize_read(buffer_fill(b)) ;
if (r <= 0) return r ;
}
return 1 ;
}
+