Go to the documentation of this file.
24 #ifndef __UTIL_SPM_H__
25 #define __UTIL_SPM_H__
67 SpmCtx *(*InitCtx)(
const uint8_t *needle, uint16_t needle_len,
int nocase,
71 const uint8_t *haystack, uint32_t haystack_len);
92 const uint8_t *haystack, uint32_t haystack_len);
95 uint8_t *
Bs2bmSearch(
const uint8_t *text, uint32_t textlen,
const uint8_t *needle, uint16_t needlelen);
96 uint8_t *
Bs2bmNocaseSearch(
const uint8_t *text, uint32_t textlen,
const uint8_t *needle, uint16_t needlelen);
97 uint8_t *
BoyerMooreSearch(
const uint8_t *text, uint32_t textlen,
const uint8_t *needle, uint16_t needlelen);
98 uint8_t *
BoyerMooreNocaseSearch(
const uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen);
101 #define SpmSearch(text, textlen, needle, needlelen) ({\
103 if (needlelen < 4 && textlen < 512) \
104 mfound = BasicSearch(text, textlen, needle, needlelen); \
105 else if (needlelen < 4) \
106 mfound = BasicSearch(text, textlen, needle, needlelen); \
108 mfound = BoyerMooreSearch(text, textlen, needle, needlelen); \
112 #define SpmNocaseSearch(text, textlen, needle, needlelen) ({\
114 if (needlelen < 4 && textlen < 512) \
115 mfound = BasicSearchNocase(text, textlen, needle, needlelen); \
116 else if (needlelen < 4) \
117 mfound = BasicSearchNocase(text, textlen, needle, needlelen); \
119 mfound = BoyerMooreNocaseSearch(text, textlen, needle, needlelen); \
struct SpmGlobalThreadCtx_ SpmGlobalThreadCtx
SpmCtx * SpmInitCtx(const uint8_t *needle, uint16_t needle_len, int nocase, SpmGlobalThreadCtx *g_thread_ctx)
uint8_t * SpmScan(const SpmCtx *ctx, SpmThreadCtx *thread_ctx, const uint8_t *haystack, uint32_t haystack_len)
uint8_t * BoyerMooreNocaseSearch(const uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using Boyer Moore nocase algorithm (build a bad character shifts array a...
uint8_t * BoyerMooreSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using Boyer Moore algorithm (build a bad character shifts array and good...
uint8_t * Bs2bmSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using the Bs2Bm algorithm (build a bad characters array)
void SpmDestroyGlobalThreadCtx(SpmGlobalThreadCtx *g_thread_ctx)
SpmThreadCtx * SpmMakeThreadCtx(const SpmGlobalThreadCtx *g_thread_ctx)
void SpmDestroyCtx(SpmCtx *ctx)
SpmTableElmt spm_table[SPM_TABLE_SIZE]
SpmGlobalThreadCtx * SpmInitGlobalThreadCtx(uint16_t matcher)
void(* DestroyCtx)(SpmCtx *)
struct SpmTableElmt_ SpmTableElmt
void SpmDestroyThreadCtx(SpmThreadCtx *thread_ctx)
uint16_t SinglePatternMatchDefaultMatcher(void)
Returns the single pattern matcher algorithm to be used, based on the spm-algo setting in yaml.
uint8_t * Bs2bmNocaseSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using the Bs2Bm nocase algorithm (build a bad characters array)
void UtilSpmSearchRegistertests(void)
struct SpmThreadCtx_ SpmThreadCtx
void(* DestroyThreadCtx)(SpmThreadCtx *thread_ctx)
void(* DestroyGlobalThreadCtx)(SpmGlobalThreadCtx *g_thread_ctx)