48 uint8_t *
BasicSearch(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
53 const uint8_t *hmax = haystack + haystack_len;
54 const uint8_t *nmax = needle + needle_len;
56 if (needle_len == 0 || needle_len > haystack_len) {
64 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
65 if (*haystack != *n) {
69 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
72 if (needle_len == 1) {
76 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
80 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
102 uint8_t *
BasicSearchNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
104 const uint8_t *h, *n;
105 const uint8_t *hmax = haystack + haystack_len;
106 const uint8_t *nmax = needle + needle_len;
108 if (needle_len == 0 || needle_len > haystack_len)
111 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
116 if (needle_len == 1) {
117 return (uint8_t *)haystack;
120 for (h = haystack+1, n++; nmax - n <= hmax - h ; h++, n++) {
126 return (uint8_t *)haystack;