diff options
Diffstat (limited to 'src/regex/regex_internal.h')
-rw-r--r-- | src/regex/regex_internal.h | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index 43686b5e2..ab8b6f22d 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file src/regex/regex_internal.h | 21 | * @file src/regex/regex_internal.h |
22 | * @brief common internal definitions for regex library. | 22 | * @brief common internal definitions for regex library. |
@@ -47,8 +47,7 @@ extern "C" | |||
47 | * which they origin ('from_state'). Each state can have 0-n transitions. | 47 | * 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. | 48 | * If label is NULL, this is considered to be an epsilon transition. |
49 | */ | 49 | */ |
50 | struct REGEX_INTERNAL_Transition | 50 | struct REGEX_INTERNAL_Transition { |
51 | { | ||
52 | /** | 51 | /** |
53 | * This is a linked list. | 52 | * This is a linked list. |
54 | */ | 53 | */ |
@@ -90,8 +89,7 @@ struct REGEX_INTERNAL_State; | |||
90 | /** | 89 | /** |
91 | * Set of states. | 90 | * Set of states. |
92 | */ | 91 | */ |
93 | struct REGEX_INTERNAL_StateSet | 92 | struct REGEX_INTERNAL_StateSet { |
94 | { | ||
95 | /** | 93 | /** |
96 | * Array of states. | 94 | * Array of states. |
97 | */ | 95 | */ |
@@ -112,8 +110,7 @@ struct REGEX_INTERNAL_StateSet | |||
112 | /** | 110 | /** |
113 | * A state. Can be used in DFA and NFA automatons. | 111 | * A state. Can be used in DFA and NFA automatons. |
114 | */ | 112 | */ |
115 | struct REGEX_INTERNAL_State | 113 | struct REGEX_INTERNAL_State { |
116 | { | ||
117 | /** | 114 | /** |
118 | * This is a linked list to keep states in an automaton. | 115 | * This is a linked list to keep states in an automaton. |
119 | */ | 116 | */ |
@@ -245,8 +242,7 @@ struct REGEX_INTERNAL_State | |||
245 | /** | 242 | /** |
246 | * Type of an automaton. | 243 | * Type of an automaton. |
247 | */ | 244 | */ |
248 | enum REGEX_INTERNAL_AutomatonType | 245 | enum REGEX_INTERNAL_AutomatonType { |
249 | { | ||
250 | NFA, | 246 | NFA, |
251 | DFA | 247 | DFA |
252 | }; | 248 | }; |
@@ -255,8 +251,7 @@ enum REGEX_INTERNAL_AutomatonType | |||
255 | /** | 251 | /** |
256 | * Automaton representation. | 252 | * Automaton representation. |
257 | */ | 253 | */ |
258 | struct REGEX_INTERNAL_Automaton | 254 | struct REGEX_INTERNAL_Automaton { |
259 | { | ||
260 | /** | 255 | /** |
261 | * Linked list of NFAs used for partial NFA creation. | 256 | * Linked list of NFAs used for partial NFA creation. |
262 | */ | 257 | */ |
@@ -324,7 +319,7 @@ struct REGEX_INTERNAL_Automaton | |||
324 | * @return NFA, needs to be freed using REGEX_INTERNAL_automaton_destroy. | 319 | * @return NFA, needs to be freed using REGEX_INTERNAL_automaton_destroy. |
325 | */ | 320 | */ |
326 | struct REGEX_INTERNAL_Automaton * | 321 | struct REGEX_INTERNAL_Automaton * |
327 | REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len); | 322 | REGEX_INTERNAL_construct_nfa(const char *regex, const size_t len); |
328 | 323 | ||
329 | 324 | ||
330 | /** | 325 | /** |
@@ -340,8 +335,8 @@ REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len); | |||
340 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. | 335 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. |
341 | */ | 336 | */ |
342 | typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | 337 | typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, |
343 | struct REGEX_INTERNAL_State * s, | 338 | struct REGEX_INTERNAL_State * s, |
344 | struct REGEX_INTERNAL_Transition * t); | 339 | struct REGEX_INTERNAL_Transition * t); |
345 | 340 | ||
346 | 341 | ||
347 | /** | 342 | /** |
@@ -352,8 +347,8 @@ typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | |||
352 | * @param s state. | 347 | * @param s state. |
353 | */ | 348 | */ |
354 | typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, | 349 | typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, |
355 | const unsigned int count, | 350 | const unsigned int count, |
356 | struct REGEX_INTERNAL_State * s); | 351 | struct REGEX_INTERNAL_State * s); |
357 | 352 | ||
358 | 353 | ||
359 | /** | 354 | /** |
@@ -370,12 +365,12 @@ typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, | |||
370 | * @param action_cls closure for action | 365 | * @param action_cls closure for action |
371 | */ | 366 | */ |
372 | void | 367 | void |
373 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, | 368 | REGEX_INTERNAL_automaton_traverse(const struct REGEX_INTERNAL_Automaton *a, |
374 | struct REGEX_INTERNAL_State *start, | 369 | struct REGEX_INTERNAL_State *start, |
375 | REGEX_INTERNAL_traverse_check check, | 370 | REGEX_INTERNAL_traverse_check check, |
376 | void *check_cls, | 371 | void *check_cls, |
377 | REGEX_INTERNAL_traverse_action action, | 372 | REGEX_INTERNAL_traverse_action action, |
378 | void *action_cls); | 373 | void *action_cls); |
379 | 374 | ||
380 | /** | 375 | /** |
381 | * Get the canonical regex of the given automaton. | 376 | * Get the canonical regex of the given automaton. |
@@ -389,7 +384,7 @@ REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, | |||
389 | * @return canonical regex string. | 384 | * @return canonical regex string. |
390 | */ | 385 | */ |
391 | const char * | 386 | const char * |
392 | REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a); | 387 | REGEX_INTERNAL_get_canonical_regex(struct REGEX_INTERNAL_Automaton *a); |
393 | 388 | ||
394 | 389 | ||
395 | /** | 390 | /** |
@@ -400,15 +395,14 @@ REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a); | |||
400 | * @return number of transitions in the given automaton. | 395 | * @return number of transitions in the given automaton. |
401 | */ | 396 | */ |
402 | unsigned int | 397 | unsigned int |
403 | REGEX_INTERNAL_get_transition_count (struct REGEX_INTERNAL_Automaton *a); | 398 | REGEX_INTERNAL_get_transition_count(struct REGEX_INTERNAL_Automaton *a); |
404 | 399 | ||
405 | 400 | ||
406 | /** | 401 | /** |
407 | * Context that contains an id counter for states and transitions as well as a | 402 | * Context that contains an id counter for states and transitions as well as a |
408 | * DLL of automatons used as a stack for NFA construction. | 403 | * DLL of automatons used as a stack for NFA construction. |
409 | */ | 404 | */ |
410 | struct REGEX_INTERNAL_Context | 405 | struct REGEX_INTERNAL_Context { |
411 | { | ||
412 | /** | 406 | /** |
413 | * Unique state id. | 407 | * Unique state id. |
414 | */ | 408 | */ |
@@ -439,9 +433,9 @@ struct REGEX_INTERNAL_Context | |||
439 | * @param stride_len length of the strides. | 433 | * @param stride_len length of the strides. |
440 | */ | 434 | */ |
441 | void | 435 | void |
442 | REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, | 436 | REGEX_INTERNAL_dfa_add_multi_strides(struct REGEX_INTERNAL_Context *regex_ctx, |
443 | struct REGEX_INTERNAL_Automaton *dfa, | 437 | struct REGEX_INTERNAL_Automaton *dfa, |
444 | const unsigned int stride_len); | 438 | const unsigned int stride_len); |
445 | 439 | ||
446 | 440 | ||
447 | 441 | ||