diff options
Diffstat (limited to 'src/regex/regex_internal.h')
-rw-r--r-- | src/regex/regex_internal.h | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index ab8b6f22d..1e0722136 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -39,7 +39,8 @@ extern "C" | |||
39 | * char array of literals that are allowed inside a regex (apart from the | 39 | * char array of literals that are allowed inside a regex (apart from the |
40 | * operators) | 40 | * operators) |
41 | */ | 41 | */ |
42 | #define ALLOWED_LITERALS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | 42 | #define ALLOWED_LITERALS \ |
43 | "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
43 | 44 | ||
44 | 45 | ||
45 | /** | 46 | /** |
@@ -47,7 +48,8 @@ extern "C" | |||
47 | * which they origin ('from_state'). Each state can have 0-n transitions. | 48 | * which they origin ('from_state'). Each state can have 0-n transitions. |
48 | * If label is NULL, this is considered to be an epsilon transition. | 49 | * If label is NULL, this is considered to be an epsilon transition. |
49 | */ | 50 | */ |
50 | struct REGEX_INTERNAL_Transition { | 51 | struct REGEX_INTERNAL_Transition |
52 | { | ||
51 | /** | 53 | /** |
52 | * This is a linked list. | 54 | * This is a linked list. |
53 | */ | 55 | */ |
@@ -89,7 +91,8 @@ struct REGEX_INTERNAL_State; | |||
89 | /** | 91 | /** |
90 | * Set of states. | 92 | * Set of states. |
91 | */ | 93 | */ |
92 | struct REGEX_INTERNAL_StateSet { | 94 | struct REGEX_INTERNAL_StateSet |
95 | { | ||
93 | /** | 96 | /** |
94 | * Array of states. | 97 | * Array of states. |
95 | */ | 98 | */ |
@@ -110,7 +113,8 @@ struct REGEX_INTERNAL_StateSet { | |||
110 | /** | 113 | /** |
111 | * A state. Can be used in DFA and NFA automatons. | 114 | * A state. Can be used in DFA and NFA automatons. |
112 | */ | 115 | */ |
113 | struct REGEX_INTERNAL_State { | 116 | struct REGEX_INTERNAL_State |
117 | { | ||
114 | /** | 118 | /** |
115 | * This is a linked list to keep states in an automaton. | 119 | * This is a linked list to keep states in an automaton. |
116 | */ | 120 | */ |
@@ -242,7 +246,8 @@ struct REGEX_INTERNAL_State { | |||
242 | /** | 246 | /** |
243 | * Type of an automaton. | 247 | * Type of an automaton. |
244 | */ | 248 | */ |
245 | enum REGEX_INTERNAL_AutomatonType { | 249 | enum REGEX_INTERNAL_AutomatonType |
250 | { | ||
246 | NFA, | 251 | NFA, |
247 | DFA | 252 | DFA |
248 | }; | 253 | }; |
@@ -251,7 +256,8 @@ enum REGEX_INTERNAL_AutomatonType { | |||
251 | /** | 256 | /** |
252 | * Automaton representation. | 257 | * Automaton representation. |
253 | */ | 258 | */ |
254 | struct REGEX_INTERNAL_Automaton { | 259 | struct REGEX_INTERNAL_Automaton |
260 | { | ||
255 | /** | 261 | /** |
256 | * Linked list of NFAs used for partial NFA creation. | 262 | * Linked list of NFAs used for partial NFA creation. |
257 | */ | 263 | */ |
@@ -319,7 +325,7 @@ struct REGEX_INTERNAL_Automaton { | |||
319 | * @return NFA, needs to be freed using REGEX_INTERNAL_automaton_destroy. | 325 | * @return NFA, needs to be freed using REGEX_INTERNAL_automaton_destroy. |
320 | */ | 326 | */ |
321 | struct REGEX_INTERNAL_Automaton * | 327 | struct REGEX_INTERNAL_Automaton * |
322 | REGEX_INTERNAL_construct_nfa(const char *regex, const size_t len); | 328 | REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len); |
323 | 329 | ||
324 | 330 | ||
325 | /** | 331 | /** |
@@ -335,8 +341,9 @@ REGEX_INTERNAL_construct_nfa(const char *regex, const size_t len); | |||
335 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. | 341 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. |
336 | */ | 342 | */ |
337 | typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | 343 | typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, |
338 | struct REGEX_INTERNAL_State * s, | 344 | struct REGEX_INTERNAL_State *s, |
339 | struct REGEX_INTERNAL_Transition * t); | 345 | struct REGEX_INTERNAL_Transition * |
346 | t); | ||
340 | 347 | ||
341 | 348 | ||
342 | /** | 349 | /** |
@@ -348,7 +355,7 @@ typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | |||
348 | */ | 355 | */ |
349 | typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, | 356 | typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, |
350 | const unsigned int count, | 357 | const unsigned int count, |
351 | struct REGEX_INTERNAL_State * s); | 358 | struct REGEX_INTERNAL_State *s); |
352 | 359 | ||
353 | 360 | ||
354 | /** | 361 | /** |
@@ -365,12 +372,12 @@ typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, | |||
365 | * @param action_cls closure for action | 372 | * @param action_cls closure for action |
366 | */ | 373 | */ |
367 | void | 374 | void |
368 | REGEX_INTERNAL_automaton_traverse(const struct REGEX_INTERNAL_Automaton *a, | 375 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, |
369 | struct REGEX_INTERNAL_State *start, | 376 | struct REGEX_INTERNAL_State *start, |
370 | REGEX_INTERNAL_traverse_check check, | 377 | REGEX_INTERNAL_traverse_check check, |
371 | void *check_cls, | 378 | void *check_cls, |
372 | REGEX_INTERNAL_traverse_action action, | 379 | REGEX_INTERNAL_traverse_action action, |
373 | void *action_cls); | 380 | void *action_cls); |
374 | 381 | ||
375 | /** | 382 | /** |
376 | * Get the canonical regex of the given automaton. | 383 | * Get the canonical regex of the given automaton. |
@@ -384,7 +391,7 @@ REGEX_INTERNAL_automaton_traverse(const struct REGEX_INTERNAL_Automaton *a, | |||
384 | * @return canonical regex string. | 391 | * @return canonical regex string. |
385 | */ | 392 | */ |
386 | const char * | 393 | const char * |
387 | REGEX_INTERNAL_get_canonical_regex(struct REGEX_INTERNAL_Automaton *a); | 394 | REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a); |
388 | 395 | ||
389 | 396 | ||
390 | /** | 397 | /** |
@@ -395,14 +402,15 @@ REGEX_INTERNAL_get_canonical_regex(struct REGEX_INTERNAL_Automaton *a); | |||
395 | * @return number of transitions in the given automaton. | 402 | * @return number of transitions in the given automaton. |
396 | */ | 403 | */ |
397 | unsigned int | 404 | unsigned int |
398 | REGEX_INTERNAL_get_transition_count(struct REGEX_INTERNAL_Automaton *a); | 405 | REGEX_INTERNAL_get_transition_count (struct REGEX_INTERNAL_Automaton *a); |
399 | 406 | ||
400 | 407 | ||
401 | /** | 408 | /** |
402 | * Context that contains an id counter for states and transitions as well as a | 409 | * Context that contains an id counter for states and transitions as well as a |
403 | * DLL of automatons used as a stack for NFA construction. | 410 | * DLL of automatons used as a stack for NFA construction. |
404 | */ | 411 | */ |
405 | struct REGEX_INTERNAL_Context { | 412 | struct REGEX_INTERNAL_Context |
413 | { | ||
406 | /** | 414 | /** |
407 | * Unique state id. | 415 | * Unique state id. |
408 | */ | 416 | */ |
@@ -433,9 +441,9 @@ struct REGEX_INTERNAL_Context { | |||
433 | * @param stride_len length of the strides. | 441 | * @param stride_len length of the strides. |
434 | */ | 442 | */ |
435 | void | 443 | void |
436 | REGEX_INTERNAL_dfa_add_multi_strides(struct REGEX_INTERNAL_Context *regex_ctx, | 444 | REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, |
437 | struct REGEX_INTERNAL_Automaton *dfa, | 445 | struct REGEX_INTERNAL_Automaton *dfa, |
438 | const unsigned int stride_len); | 446 | const unsigned int stride_len); |
439 | 447 | ||
440 | 448 | ||
441 | 449 | ||