Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / siovec.h / siov_bytechr.3.md

% limb manual
% siov_bytechr(3)
% limb 0.1.0
% 2023-07-24

# NAME

siov_bytechr, siov_bytein - search for bytes in an array of vectors

# SYNOPSIS

    #include <limb/siovec.h>

```pre hl
size_t siov_bytechr(const struct iovec *<em>v</em>, unsigned int <em>n</em>, char <em>c</em>)
size_t siov_bytein(const struct iovec *<em>v</em>, unsigned int <em>n</em>,
                   const char *<em>sep</em>, size_t <em>len</em>)

size_t siov_seek_bytechr(const struct iovec *<em>v</em>, unsigned int <em>n</em>, size_t <em>offset</em>, char <em>c</em>)
size_t siov_seek_bytein(const struct iovec *<em>v</em>, unsigned int <em>n</em>, size_t <em>offset</em>,
                        const char *<em>sep</em>, size_t <em>len</em>)
```

# DESCRIPTION

These functions are meant to be vectors equivalent of what [byte_chr](3) and
[byte_in](3) are for byte arrays.

The `siov_bytechr`() function scans data pointed by the array `v` of `n` vectors
for the first instance of `c`.

The `siov_bytein`() function scans data pointed by the array `v` of `n` vectors
for the first instance of any of the `len` bytes pointed by `sep`.

The `siov_seek_bytechr`() function is similar to `siov_bytechr`() only skipping
the first `offset` bytes of data.

The `siov_seek_bytein`() function is similar to `siov_bytein`() only skipping
the first `offset` bytes of data.

# RETURN VALUE

The `siov_bytechr`() and `siov_bytein`() functions return the position of the
first occurence found in the data within the array `v` of `n` vectors, or the
total length of said data otherwise.

The `siov_seek_bytechr`() and `siov_seek_bytein`() functions return the same
position, but counting from `offset`. As such, when not found, they return the
total length of data minus `offset`.

! WARN:
! Be aware that, if `offset` is larger than the amount of data in the array `v`
! of `n` vectors, they will return 0, as that amounts to the total length of
! data minus the skipped data.
! In other words, it is much simpler to never call those functions with an
! invalid offset.

# SEE ALSO

[siov_seek](3), [byte_chr](3), [byte_in](3), [siov_search](3)