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++) {
92 uint8_t *
Bs2Bm(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
93 uint16_t needle_len,
const uint8_t badchars[])
96 const uint8_t *hmax = haystack + haystack_len;
97 const uint8_t *nmax = needle + needle_len;
99 if (needle_len == 0 || needle_len > haystack_len)
102 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
103 if (*haystack != *n) {
108 return (uint8_t *)haystack;
110 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
112 if (badchars[*h] == 1) {
119 if (n == nmax - 1 ) {
120 return (uint8_t *)haystack;
142 uint8_t *
Bs2BmNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
143 uint16_t needle_len,
const uint8_t badchars[])
145 const uint8_t *h, *n;
146 const uint8_t *hmax = haystack + haystack_len;
147 const uint8_t *nmax = needle + needle_len;
149 if (needle_len == 0 || needle_len > haystack_len)
152 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
158 return (uint8_t *)haystack;
160 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
170 return (uint8_t *)haystack;