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

#include <sys/types.h>
#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 ;
}