47 uint8_t *
BasicSearch(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
52 const uint8_t *hmax = haystack + haystack_len;
53 const uint8_t *nmax = needle + needle_len;
55 if (needle_len == 0 || needle_len > haystack_len) {
63 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
64 if (*haystack != *n) {
68 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
71 if (needle_len == 1) {
75 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
79 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
101 uint8_t *
BasicSearchNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
103 const uint8_t *h, *n;
104 const uint8_t *hmax = haystack + haystack_len;
105 const uint8_t *nmax = needle + needle_len;
107 if (needle_len == 0 || needle_len > haystack_len)
110 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
115 if (needle_len == 1) {
116 return (uint8_t *)haystack;
119 for (h = haystack+1, n++; nmax - n <= hmax - h ; h++, n++) {
125 return (uint8_t *)haystack;
135 const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
141 return (uint32_t)(r - haystack);