29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/string.h>
32 #include <linux/ctype.h>
64 static const u16 token_lookup_tbl[256] = {
133 return (token_lookup_tbl[d] & t->
type) != 0;
140 struct ts_fsm *
fsm = ts_config_priv(conf);
142 unsigned int match_start, block_idx = 0, tok_idx;
143 unsigned block_len = 0, strict, consumed = state->
offset;
146 #define GET_NEXT_BLOCK() \
147 ({ consumed += block_idx; \
149 block_len = conf->get_next_block(consumed, &data, conf, state); })
151 #define TOKEN_MISMATCH() \
159 #define end_of_data() unlikely(block_idx >= block_len && !GET_NEXT_BLOCK())
167 match_start = consumed + block_idx;
169 for (tok_idx = 0; tok_idx < fsm->
ntokens; tok_idx++) {
170 cur = &fsm->
tokens[tok_idx];
173 next = &fsm->
tokens[tok_idx + 1];
177 switch (cur->
recur) {
241 match_start = consumed + block_idx;
255 state->
offset = consumed + block_idx;
266 unsigned int ntokens = len /
sizeof(*tokens);
267 size_t priv_size =
sizeof(*fsm) + len;
275 for (i = 0; i < ntokens; i++) {
282 (i != 0 || i == (ntokens - 1)))
286 conf = alloc_ts_config(priv_size, gfp_mask);
291 fsm = ts_config_priv(conf);
295 for (i = 0; i < fsm->
ntokens; i++) {
306 static void *fsm_get_pattern(
struct ts_config *conf)
308 struct ts_fsm *fsm = ts_config_priv(conf);
312 static unsigned int fsm_get_pattern_len(
struct ts_config *conf)
314 struct ts_fsm *fsm = ts_config_priv(conf);
318 static struct ts_ops fsm_ops = {
322 .get_pattern = fsm_get_pattern,
323 .get_pattern_len = fsm_get_pattern_len,
333 static void __exit exit_fsm(
void)