summaryrefslogtreecommitdiff
path: root/src/libstddjb/buffer_getvall.c
blob: b6eeb4665f83964b17cf4cb6c07f9129bbb91bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <errno.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)
{
  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)
  {
    register int r = buffer_getall(b, v[w->left].s, v[w->left].len, &w->right) ;
    if (r <= 0) return r ;
  }
  return 1 ;
}