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

#include <errno.h>
#include <skalibs/buffer.h>
#include <skalibs/diuint.h>
#include <skalibs/siovec.h>

int buffer_putvall (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, 0) ;
  for (; w->left < n ; w->left++, w->right = 0)
    if (!buffer_putall(b, v[w->left].s, v[w->left].len, &w->right)) return 0 ;
  return 1 ;
}