byte_str(3)
limb manual
byte_str(3)
NAME
byte_str byte_istr - locate a byte array within another byte array
SYNOPSIS
#include <limb/bytestr.h>
size_t byte_str(const char *haystack, size_t hlen, const char *needle, size_t nlen) size_t byte_istr(const char *haystack, size_t hlen, const char *needle, size_t nlen)
DESCRIPTION
The byte_str
() function looks for the first occurrence of the byte array
needle
of length nlen
in the byte array haystack
of length hlen
.
Neither haystack
nor needle
need be NUL-terminated, and in fact can contain
themselves bytes of any value.
The byte_istr
() function is similar but performing case-insensitive
comparisons for the current locale. (Specifically, it relies on tolower(3).)
Warning
Unless both arrays are small, the byte_istr
() function will perform poorly.
RETURN VALUE
The byte_str
() and byte_istr
() functions return the offset of the first
occurrence of needle
within haystack
if found. Otherwise, they returns
hlen
.