limb 0.2.0

2024-01-09

siov_bytechr(3)
limb manual
siov_bytechr(3)

NAME

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

SYNOPSIS

#include <limb/siovec.h>
size_t siov_bytechr(const struct iovec *v, unsigned int n, char c)
size_t siov_bytein(const struct iovec *v, unsigned int n,
                   const char *sep, size_t len)

size_t siov_seek_bytechr(const struct iovec *v, unsigned int n, size_t offset, char c)
size_t siov_seek_bytein(const struct iovec *v, unsigned int n, size_t offset,
                        const char *sep, size_t len)

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.

Warning

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)

limb 0.1.0
2023-07-24
siov_bytechr(3)