43 void Bs2BmBadchars(
const uint8_t *needle, uint16_t needle_len, uint8_t *badchars)
52 for (i = 0; i < needle_len; i++)
53 badchars[needle[i]] = 0;
74 for (i = 0; i < needle_len; i++) {
93 uint8_t *
Bs2Bm(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
94 uint16_t needle_len,
const uint8_t badchars[])
97 const uint8_t *hmax = haystack + haystack_len;
98 const uint8_t *nmax = needle + needle_len;
100 if (needle_len == 0 || needle_len > haystack_len)
103 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
104 if (*haystack != *n) {
109 return (uint8_t *)haystack;
111 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
113 if (badchars[*h] == 1) {
120 if (n == nmax - 1 ) {
121 return (uint8_t *)haystack;
143 uint8_t *
Bs2BmNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
144 uint16_t needle_len,
const uint8_t badchars[])
146 const uint8_t *h, *n;
147 const uint8_t *hmax = haystack + haystack_len;
148 const uint8_t *nmax = needle + needle_len;
150 if (needle_len == 0 || needle_len > haystack_len)
153 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
159 return (uint8_t *)haystack;
161 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
171 return (uint8_t *)haystack;