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

#include <sys/uio.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>

size_t siovec_bytein (struct iovec const *v, unsigned int n, char const *sep, size_t seplen)
{
  size_t w = 0 ;
  unsigned int i = 0 ;
  for (; i < n ; i++)
  {
    size_t pos = byte_in((char const *)v[i].iov_base, v[i].iov_len, sep, seplen) ;
    w += pos ;
    if (pos < v[i].iov_len) break ;
  }
  return w ;
}