summary refs log tree commit diff
path: root/src/libstddjb/siovec_bytechr.c
blob: 295b949a2fdec0a578e5176d6734fa154e9b5b8a (plain) (blame)
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_bytechr (struct iovec const *v, unsigned int n, char c)
{
  size_t w = 0 ;
  unsigned int i = 0 ;
  for (; i < n ; i++)
  {
    size_t pos = byte_chr((char const *)v[i].iov_base, v[i].iov_len, c) ;
    w += pos ;
    if (pos < v[i].iov_len) break ;
  }
  return w ;
}