49 uint8_t *
BasicSearch(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
53 return memmem(haystack, haystack_len, needle, needle_len);
56 const uint8_t *hmax = haystack + haystack_len;
57 const uint8_t *nmax = needle + needle_len;
59 if (needle_len == 0 || needle_len > haystack_len) {
67 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
68 if (*haystack != *n) {
72 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
75 if (needle_len == 1) {
79 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
83 SCLogDebug(
"*haystack == *n, %c == %c", *haystack, *n);
106 uint8_t *
BasicSearchNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
108 const uint8_t *h, *n;
109 const uint8_t *hmax = haystack + haystack_len;
110 const uint8_t *nmax = needle + needle_len;
112 if (needle_len == 0 || needle_len > haystack_len)
115 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
120 if (needle_len == 1) {
121 return (uint8_t *)haystack;
124 for (h = haystack+1, n++; nmax - n <= hmax - h ; h++, n++) {
130 return (uint8_t *)haystack;
140 const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, uint16_t needle_len)
146 return (uint32_t)(r - haystack);