summaryrefslogtreecommitdiff
path: root/src/regex/regex_internal.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-20 09:02:43 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-20 09:02:43 +0000
commit566b7539fcaf9c455da665cb641016d2cfbb1b47 (patch)
treeeb12baa08d99313d6da7eb8c1be17c5e447f1586 /src/regex/regex_internal.c
parentde9409f80dbfc5cc61a28316b271600e9da95cdc (diff)
downloadgnunet-566b7539fcaf9c455da665cb641016d2cfbb1b47.tar.gz
gnunet-566b7539fcaf9c455da665cb641016d2cfbb1b47.zip
renaming symbols from libgnunetregextest to have the prefix REGEX_TEST
Diffstat (limited to 'src/regex/regex_internal.c')
-rw-r--r--src/regex/regex_internal.c454
1 files changed, 227 insertions, 227 deletions
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c
index e66835134..6fda695a7 100644
--- a/src/regex/regex_internal.c
+++ b/src/regex/regex_internal.c
@@ -39,17 +39,17 @@
39/** 39/**
40 * Set of states using MDLL API. 40 * Set of states using MDLL API.
41 */ 41 */
42struct REGEX_ITERNAL_StateSet_MDLL 42struct REGEX_INTERNAL_StateSet_MDLL
43{ 43{
44 /** 44 /**
45 * MDLL of states. 45 * MDLL of states.
46 */ 46 */
47 struct REGEX_ITERNAL_State *head; 47 struct REGEX_INTERNAL_State *head;
48 48
49 /** 49 /**
50 * MDLL of states. 50 * MDLL of states.
51 */ 51 */
52 struct REGEX_ITERNAL_State *tail; 52 struct REGEX_INTERNAL_State *tail;
53 53
54 /** 54 /**
55 * Length of the MDLL. 55 * Length of the MDLL.
@@ -65,8 +65,8 @@ struct REGEX_ITERNAL_StateSet_MDLL
65 * @param state state to be appended 65 * @param state state to be appended
66 */ 66 */
67static void 67static void
68state_set_append (struct REGEX_ITERNAL_StateSet *set, 68state_set_append (struct REGEX_INTERNAL_StateSet *set,
69 struct REGEX_ITERNAL_State *state) 69 struct REGEX_INTERNAL_State *state)
70{ 70{
71 if (set->off == set->size) 71 if (set->off == set->size)
72 GNUNET_array_grow (set->states, set->size, set->size * 2 + 4); 72 GNUNET_array_grow (set->states, set->size, set->size * 2 + 4);
@@ -104,12 +104,12 @@ nullstrcmp (const char *str1, const char *str2)
104 * @param to_state state to where the transition should point to 104 * @param to_state state to where the transition should point to
105 */ 105 */
106static void 106static void
107state_add_transition (struct REGEX_ITERNAL_Context *ctx, 107state_add_transition (struct REGEX_INTERNAL_Context *ctx,
108 struct REGEX_ITERNAL_State *from_state, const char *label, 108 struct REGEX_INTERNAL_State *from_state, const char *label,
109 struct REGEX_ITERNAL_State *to_state) 109 struct REGEX_INTERNAL_State *to_state)
110{ 110{
111 struct REGEX_ITERNAL_Transition *t; 111 struct REGEX_INTERNAL_Transition *t;
112 struct REGEX_ITERNAL_Transition *oth; 112 struct REGEX_INTERNAL_Transition *oth;
113 113
114 if (NULL == from_state) 114 if (NULL == from_state)
115 { 115 {
@@ -132,7 +132,7 @@ state_add_transition (struct REGEX_ITERNAL_Context *ctx,
132 break; 132 break;
133 } 133 }
134 134
135 t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); 135 t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
136 if (NULL != ctx) 136 if (NULL != ctx)
137 t->id = ctx->transition_id++; 137 t->id = ctx->transition_id++;
138 if (NULL != label) 138 if (NULL != label)
@@ -156,8 +156,8 @@ state_add_transition (struct REGEX_ITERNAL_Context *ctx,
156 * @param transition transition that should be removed from state 'state'. 156 * @param transition transition that should be removed from state 'state'.
157 */ 157 */
158static void 158static void
159state_remove_transition (struct REGEX_ITERNAL_State *state, 159state_remove_transition (struct REGEX_INTERNAL_State *state,
160 struct REGEX_ITERNAL_Transition *transition) 160 struct REGEX_INTERNAL_Transition *transition)
161{ 161{
162 if (NULL == state || NULL == transition) 162 if (NULL == state || NULL == transition)
163 return; 163 return;
@@ -188,8 +188,8 @@ state_remove_transition (struct REGEX_ITERNAL_State *state,
188static int 188static int
189state_compare (const void *a, const void *b) 189state_compare (const void *a, const void *b)
190{ 190{
191 struct REGEX_ITERNAL_State **s1 = (struct REGEX_ITERNAL_State **) a; 191 struct REGEX_INTERNAL_State **s1 = (struct REGEX_INTERNAL_State **) a;
192 struct REGEX_ITERNAL_State **s2 = (struct REGEX_ITERNAL_State **) b; 192 struct REGEX_INTERNAL_State **s2 = (struct REGEX_INTERNAL_State **) b;
193 193
194 return (*s1)->id - (*s2)->id; 194 return (*s1)->id - (*s2)->id;
195} 195}
@@ -205,9 +205,9 @@ state_compare (const void *a, const void *b)
205 * @return number of edges. 205 * @return number of edges.
206 */ 206 */
207static unsigned int 207static unsigned int
208state_get_edges (struct REGEX_ITERNAL_State *s, struct REGEX_ITERNAL_Edge *edges) 208state_get_edges (struct REGEX_INTERNAL_State *s, struct REGEX_INTERNAL_Edge *edges)
209{ 209{
210 struct REGEX_ITERNAL_Transition *t; 210 struct REGEX_INTERNAL_Transition *t;
211 unsigned int count; 211 unsigned int count;
212 212
213 if (NULL == s) 213 if (NULL == s)
@@ -237,8 +237,8 @@ state_get_edges (struct REGEX_ITERNAL_State *s, struct REGEX_ITERNAL_Edge *edges
237 * @return 0 if the sets are equal, otherwise non-zero 237 * @return 0 if the sets are equal, otherwise non-zero
238 */ 238 */
239static int 239static int
240state_set_compare (struct REGEX_ITERNAL_StateSet *sset1, 240state_set_compare (struct REGEX_INTERNAL_StateSet *sset1,
241 struct REGEX_ITERNAL_StateSet *sset2) 241 struct REGEX_INTERNAL_StateSet *sset2)
242{ 242{
243 int result; 243 int result;
244 unsigned int i; 244 unsigned int i;
@@ -264,7 +264,7 @@ state_set_compare (struct REGEX_ITERNAL_StateSet *sset1,
264 * @param set set to be cleared 264 * @param set set to be cleared
265 */ 265 */
266static void 266static void
267state_set_clear (struct REGEX_ITERNAL_StateSet *set) 267state_set_clear (struct REGEX_INTERNAL_StateSet *set)
268{ 268{
269 GNUNET_array_grow (set->states, set->size, 0); 269 GNUNET_array_grow (set->states, set->size, 0);
270 set->off = 0; 270 set->off = 0;
@@ -278,7 +278,7 @@ state_set_clear (struct REGEX_ITERNAL_StateSet *set)
278 * @param a automaton to be cleared 278 * @param a automaton to be cleared
279 */ 279 */
280static void 280static void
281automaton_fragment_clear (struct REGEX_ITERNAL_Automaton *a) 281automaton_fragment_clear (struct REGEX_INTERNAL_Automaton *a)
282{ 282{
283 if (NULL == a) 283 if (NULL == a)
284 return; 284 return;
@@ -298,10 +298,10 @@ automaton_fragment_clear (struct REGEX_ITERNAL_Automaton *a)
298 * @param s state that should be destroyed 298 * @param s state that should be destroyed
299 */ 299 */
300static void 300static void
301automaton_destroy_state (struct REGEX_ITERNAL_State *s) 301automaton_destroy_state (struct REGEX_INTERNAL_State *s)
302{ 302{
303 struct REGEX_ITERNAL_Transition *t; 303 struct REGEX_INTERNAL_Transition *t;
304 struct REGEX_ITERNAL_Transition *next_t; 304 struct REGEX_INTERNAL_Transition *next_t;
305 305
306 if (NULL == s) 306 if (NULL == s)
307 return; 307 return;
@@ -328,12 +328,12 @@ automaton_destroy_state (struct REGEX_ITERNAL_State *s)
328 * @param s state to remove 328 * @param s state to remove
329 */ 329 */
330static void 330static void
331automaton_remove_state (struct REGEX_ITERNAL_Automaton *a, 331automaton_remove_state (struct REGEX_INTERNAL_Automaton *a,
332 struct REGEX_ITERNAL_State *s) 332 struct REGEX_INTERNAL_State *s)
333{ 333{
334 struct REGEX_ITERNAL_State *s_check; 334 struct REGEX_INTERNAL_State *s_check;
335 struct REGEX_ITERNAL_Transition *t_check; 335 struct REGEX_INTERNAL_Transition *t_check;
336 struct REGEX_ITERNAL_Transition *t_check_next; 336 struct REGEX_INTERNAL_Transition *t_check_next;
337 337
338 if (NULL == a || NULL == s) 338 if (NULL == a || NULL == s)
339 return; 339 return;
@@ -368,15 +368,15 @@ automaton_remove_state (struct REGEX_ITERNAL_Automaton *a,
368 * @param s2 second state, will be destroyed 368 * @param s2 second state, will be destroyed
369 */ 369 */
370static void 370static void
371automaton_merge_states (struct REGEX_ITERNAL_Context *ctx, 371automaton_merge_states (struct REGEX_INTERNAL_Context *ctx,
372 struct REGEX_ITERNAL_Automaton *a, 372 struct REGEX_INTERNAL_Automaton *a,
373 struct REGEX_ITERNAL_State *s1, 373 struct REGEX_INTERNAL_State *s1,
374 struct REGEX_ITERNAL_State *s2) 374 struct REGEX_INTERNAL_State *s2)
375{ 375{
376 struct REGEX_ITERNAL_State *s_check; 376 struct REGEX_INTERNAL_State *s_check;
377 struct REGEX_ITERNAL_Transition *t_check; 377 struct REGEX_INTERNAL_Transition *t_check;
378 struct REGEX_ITERNAL_Transition *t; 378 struct REGEX_INTERNAL_Transition *t;
379 struct REGEX_ITERNAL_Transition *t_next; 379 struct REGEX_INTERNAL_Transition *t_next;
380 int is_dup; 380 int is_dup;
381 381
382 if (s1 == s2) 382 if (s1 == s2)
@@ -437,8 +437,8 @@ automaton_merge_states (struct REGEX_ITERNAL_Context *ctx,
437 * @param s state that should be added 437 * @param s state that should be added
438 */ 438 */
439static void 439static void
440automaton_add_state (struct REGEX_ITERNAL_Automaton *a, 440automaton_add_state (struct REGEX_INTERNAL_Automaton *a,
441 struct REGEX_ITERNAL_State *s) 441 struct REGEX_INTERNAL_State *s)
442{ 442{
443 GNUNET_CONTAINER_DLL_insert (a->states_head, a->states_tail, s); 443 GNUNET_CONTAINER_DLL_insert (a->states_head, a->states_tail, s);
444 a->state_count++; 444 a->state_count++;
@@ -460,12 +460,12 @@ automaton_add_state (struct REGEX_ITERNAL_Automaton *a,
460 * @param action_cls closure for action. 460 * @param action_cls closure for action.
461 */ 461 */
462static void 462static void
463automaton_state_traverse (struct REGEX_ITERNAL_State *s, int *marks, 463automaton_state_traverse (struct REGEX_INTERNAL_State *s, int *marks,
464 unsigned int *count, 464 unsigned int *count,
465 REGEX_ITERNAL_traverse_check check, void *check_cls, 465 REGEX_INTERNAL_traverse_check check, void *check_cls,
466 REGEX_ITERNAL_traverse_action action, void *action_cls) 466 REGEX_INTERNAL_traverse_action action, void *action_cls)
467{ 467{
468 struct REGEX_ITERNAL_Transition *t; 468 struct REGEX_INTERNAL_Transition *t;
469 469
470 if (GNUNET_YES == marks[s->traversal_id]) 470 if (GNUNET_YES == marks[s->traversal_id])
471 return; 471 return;
@@ -503,15 +503,15 @@ automaton_state_traverse (struct REGEX_ITERNAL_State *s, int *marks,
503 * @param action_cls closure for action 503 * @param action_cls closure for action
504 */ 504 */
505void 505void
506REGEX_ITERNAL_automaton_traverse (const struct REGEX_ITERNAL_Automaton *a, 506REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a,
507 struct REGEX_ITERNAL_State *start, 507 struct REGEX_INTERNAL_State *start,
508 REGEX_ITERNAL_traverse_check check, 508 REGEX_INTERNAL_traverse_check check,
509 void *check_cls, 509 void *check_cls,
510 REGEX_ITERNAL_traverse_action action, 510 REGEX_INTERNAL_traverse_action action,
511 void *action_cls) 511 void *action_cls)
512{ 512{
513 unsigned int count; 513 unsigned int count;
514 struct REGEX_ITERNAL_State *s; 514 struct REGEX_INTERNAL_State *s;
515 515
516 if (NULL == a || 0 == a->state_count) 516 if (NULL == a || 0 == a->state_count)
517 return; 517 return;
@@ -1156,7 +1156,7 @@ sb_strkcmp (const struct StringBuffer *str1,
1156 1156
1157 1157
1158/** 1158/**
1159 * Helper function used as 'action' in 'REGEX_ITERNAL_automaton_traverse' 1159 * Helper function used as 'action' in 'REGEX_INTERNAL_automaton_traverse'
1160 * function to create the depth-first numbering of the states. 1160 * function to create the depth-first numbering of the states.
1161 * 1161 *
1162 * @param cls states array. 1162 * @param cls states array.
@@ -1165,9 +1165,9 @@ sb_strkcmp (const struct StringBuffer *str1,
1165 */ 1165 */
1166static void 1166static void
1167number_states (void *cls, const unsigned int count, 1167number_states (void *cls, const unsigned int count,
1168 struct REGEX_ITERNAL_State *s) 1168 struct REGEX_INTERNAL_State *s)
1169{ 1169{
1170 struct REGEX_ITERNAL_State **states = cls; 1170 struct REGEX_INTERNAL_State **states = cls;
1171 1171
1172 s->dfs_id = count; 1172 s->dfs_id = count;
1173 if (NULL != states) 1173 if (NULL != states)
@@ -1604,16 +1604,16 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij,
1604 * @param a automaton for which to assign proofs and hashes, must not be NULL 1604 * @param a automaton for which to assign proofs and hashes, must not be NULL
1605 */ 1605 */
1606static int 1606static int
1607automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a) 1607automaton_create_proofs (struct REGEX_INTERNAL_Automaton *a)
1608{ 1608{
1609 unsigned int n = a->state_count; 1609 unsigned int n = a->state_count;
1610 struct REGEX_ITERNAL_State *states[n]; 1610 struct REGEX_INTERNAL_State *states[n];
1611 struct StringBuffer *R_last; 1611 struct StringBuffer *R_last;
1612 struct StringBuffer *R_cur; 1612 struct StringBuffer *R_cur;
1613 struct StringBuffer R_cur_r; 1613 struct StringBuffer R_cur_r;
1614 struct StringBuffer R_cur_l; 1614 struct StringBuffer R_cur_l;
1615 struct StringBuffer *R_swap; 1615 struct StringBuffer *R_swap;
1616 struct REGEX_ITERNAL_Transition *t; 1616 struct REGEX_INTERNAL_Transition *t;
1617 struct StringBuffer complete_regex; 1617 struct StringBuffer complete_regex;
1618 unsigned int i; 1618 unsigned int i;
1619 unsigned int j; 1619 unsigned int j;
@@ -1631,7 +1631,7 @@ automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a)
1631 } 1631 }
1632 1632
1633 /* create depth-first numbering of the states, initializes 'state' */ 1633 /* create depth-first numbering of the states, initializes 'state' */
1634 REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &number_states, 1634 REGEX_INTERNAL_automaton_traverse (a, a->start, NULL, NULL, &number_states,
1635 states); 1635 states);
1636 1636
1637 for (i = 0; i < n; i++) 1637 for (i = 0; i < n; i++)
@@ -1763,18 +1763,18 @@ automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a)
1763 * 1763 *
1764 * @return new DFA state 1764 * @return new DFA state
1765 */ 1765 */
1766static struct REGEX_ITERNAL_State * 1766static struct REGEX_INTERNAL_State *
1767dfa_state_create (struct REGEX_ITERNAL_Context *ctx, 1767dfa_state_create (struct REGEX_INTERNAL_Context *ctx,
1768 struct REGEX_ITERNAL_StateSet *nfa_states) 1768 struct REGEX_INTERNAL_StateSet *nfa_states)
1769{ 1769{
1770 struct REGEX_ITERNAL_State *s; 1770 struct REGEX_INTERNAL_State *s;
1771 char *pos; 1771 char *pos;
1772 size_t len; 1772 size_t len;
1773 struct REGEX_ITERNAL_State *cstate; 1773 struct REGEX_INTERNAL_State *cstate;
1774 struct REGEX_ITERNAL_Transition *ctran; 1774 struct REGEX_INTERNAL_Transition *ctran;
1775 unsigned int i; 1775 unsigned int i;
1776 1776
1777 s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State)); 1777 s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State));
1778 s->id = ctx->state_id++; 1778 s->id = ctx->state_id++;
1779 s->index = -1; 1779 s->index = -1;
1780 s->lowlink = -1; 1780 s->lowlink = -1;
@@ -1816,7 +1816,7 @@ dfa_state_create (struct REGEX_ITERNAL_Context *ctx,
1816 pos[-1] = '}'; 1816 pos[-1] = '}';
1817 s->name = GNUNET_realloc (s->name, strlen (s->name) + 1); 1817 s->name = GNUNET_realloc (s->name, strlen (s->name) + 1);
1818 1818
1819 memset (nfa_states, 0, sizeof (struct REGEX_ITERNAL_StateSet)); 1819 memset (nfa_states, 0, sizeof (struct REGEX_INTERNAL_StateSet));
1820 return s; 1820 return s;
1821} 1821}
1822 1822
@@ -1835,10 +1835,10 @@ dfa_state_create (struct REGEX_ITERNAL_Context *ctx,
1835 * @return length of the substring comsumed from 'str' 1835 * @return length of the substring comsumed from 'str'
1836 */ 1836 */
1837static unsigned int 1837static unsigned int
1838dfa_move (struct REGEX_ITERNAL_State **s, const char *str) 1838dfa_move (struct REGEX_INTERNAL_State **s, const char *str)
1839{ 1839{
1840 struct REGEX_ITERNAL_Transition *t; 1840 struct REGEX_INTERNAL_Transition *t;
1841 struct REGEX_ITERNAL_State *new_s; 1841 struct REGEX_INTERNAL_State *new_s;
1842 unsigned int len; 1842 unsigned int len;
1843 unsigned int max_len; 1843 unsigned int max_len;
1844 1844
@@ -1876,7 +1876,7 @@ dfa_move (struct REGEX_ITERNAL_State **s, const char *str)
1876 * @param s state where the marked attribute will be set to GNUNET_YES. 1876 * @param s state where the marked attribute will be set to GNUNET_YES.
1877 */ 1877 */
1878static void 1878static void
1879mark_states (void *cls, const unsigned int count, struct REGEX_ITERNAL_State *s) 1879mark_states (void *cls, const unsigned int count, struct REGEX_INTERNAL_State *s)
1880{ 1880{
1881 s->marked = GNUNET_YES; 1881 s->marked = GNUNET_YES;
1882} 1882}
@@ -1889,17 +1889,17 @@ mark_states (void *cls, const unsigned int count, struct REGEX_ITERNAL_State *s)
1889 * @param a DFA automaton 1889 * @param a DFA automaton
1890 */ 1890 */
1891static void 1891static void
1892dfa_remove_unreachable_states (struct REGEX_ITERNAL_Automaton *a) 1892dfa_remove_unreachable_states (struct REGEX_INTERNAL_Automaton *a)
1893{ 1893{
1894 struct REGEX_ITERNAL_State *s; 1894 struct REGEX_INTERNAL_State *s;
1895 struct REGEX_ITERNAL_State *s_next; 1895 struct REGEX_INTERNAL_State *s_next;
1896 1896
1897 /* 1. unmark all states */ 1897 /* 1. unmark all states */
1898 for (s = a->states_head; NULL != s; s = s->next) 1898 for (s = a->states_head; NULL != s; s = s->next)
1899 s->marked = GNUNET_NO; 1899 s->marked = GNUNET_NO;
1900 1900
1901 /* 2. traverse dfa from start state and mark all visited states */ 1901 /* 2. traverse dfa from start state and mark all visited states */
1902 REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL); 1902 REGEX_INTERNAL_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL);
1903 1903
1904 /* 3. delete all states that were not visited */ 1904 /* 3. delete all states that were not visited */
1905 for (s = a->states_head; NULL != s; s = s_next) 1905 for (s = a->states_head; NULL != s; s = s_next)
@@ -1918,11 +1918,11 @@ dfa_remove_unreachable_states (struct REGEX_ITERNAL_Automaton *a)
1918 * @param a DFA automaton 1918 * @param a DFA automaton
1919 */ 1919 */
1920static void 1920static void
1921dfa_remove_dead_states (struct REGEX_ITERNAL_Automaton *a) 1921dfa_remove_dead_states (struct REGEX_INTERNAL_Automaton *a)
1922{ 1922{
1923 struct REGEX_ITERNAL_State *s; 1923 struct REGEX_INTERNAL_State *s;
1924 struct REGEX_ITERNAL_State *s_next; 1924 struct REGEX_INTERNAL_State *s_next;
1925 struct REGEX_ITERNAL_Transition *t; 1925 struct REGEX_INTERNAL_Transition *t;
1926 int dead; 1926 int dead;
1927 1927
1928 GNUNET_assert (DFA == a->type); 1928 GNUNET_assert (DFA == a->type);
@@ -1961,16 +1961,16 @@ dfa_remove_dead_states (struct REGEX_ITERNAL_Automaton *a)
1961 * @return GNUNET_OK on success 1961 * @return GNUNET_OK on success
1962 */ 1962 */
1963static int 1963static int
1964dfa_merge_nondistinguishable_states (struct REGEX_ITERNAL_Context *ctx, 1964dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx,
1965 struct REGEX_ITERNAL_Automaton *a) 1965 struct REGEX_INTERNAL_Automaton *a)
1966{ 1966{
1967 uint32_t *table; 1967 uint32_t *table;
1968 struct REGEX_ITERNAL_State *s1; 1968 struct REGEX_INTERNAL_State *s1;
1969 struct REGEX_ITERNAL_State *s2; 1969 struct REGEX_INTERNAL_State *s2;
1970 struct REGEX_ITERNAL_Transition *t1; 1970 struct REGEX_INTERNAL_Transition *t1;
1971 struct REGEX_ITERNAL_Transition *t2; 1971 struct REGEX_INTERNAL_Transition *t2;
1972 struct REGEX_ITERNAL_State *s1_next; 1972 struct REGEX_INTERNAL_State *s1_next;
1973 struct REGEX_ITERNAL_State *s2_next; 1973 struct REGEX_INTERNAL_State *s2_next;
1974 int change; 1974 int change;
1975 unsigned int num_equal_edges; 1975 unsigned int num_equal_edges;
1976 unsigned int i; 1976 unsigned int i;
@@ -2078,8 +2078,8 @@ dfa_merge_nondistinguishable_states (struct REGEX_ITERNAL_Context *ctx,
2078 * @return GNUNET_OK on success 2078 * @return GNUNET_OK on success
2079 */ 2079 */
2080static int 2080static int
2081dfa_minimize (struct REGEX_ITERNAL_Context *ctx, 2081dfa_minimize (struct REGEX_INTERNAL_Context *ctx,
2082 struct REGEX_ITERNAL_Automaton *a) 2082 struct REGEX_INTERNAL_Automaton *a)
2083{ 2083{
2084 if (NULL == a) 2084 if (NULL == a)
2085 return GNUNET_SYSERR; 2085 return GNUNET_SYSERR;
@@ -2102,7 +2102,7 @@ dfa_minimize (struct REGEX_ITERNAL_Context *ctx,
2102/** 2102/**
2103 * Context for adding strided transitions to a DFA. 2103 * Context for adding strided transitions to a DFA.
2104 */ 2104 */
2105struct REGEX_ITERNAL_Strided_Context 2105struct REGEX_INTERNAL_Strided_Context
2106{ 2106{
2107 /** 2107 /**
2108 * Length of the strides. 2108 * Length of the strides.
@@ -2113,12 +2113,12 @@ struct REGEX_ITERNAL_Strided_Context
2113 * Strided transitions DLL. New strided transitions will be stored in this DLL 2113 * Strided transitions DLL. New strided transitions will be stored in this DLL
2114 * and afterwards added to the DFA. 2114 * and afterwards added to the DFA.
2115 */ 2115 */
2116 struct REGEX_ITERNAL_Transition *transitions_head; 2116 struct REGEX_INTERNAL_Transition *transitions_head;
2117 2117
2118 /** 2118 /**
2119 * Strided transitions DLL. 2119 * Strided transitions DLL.
2120 */ 2120 */
2121 struct REGEX_ITERNAL_Transition *transitions_tail; 2121 struct REGEX_INTERNAL_Transition *transitions_tail;
2122}; 2122};
2123 2123
2124 2124
@@ -2134,16 +2134,16 @@ struct REGEX_ITERNAL_Strided_Context
2134 */ 2134 */
2135void 2135void
2136dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, 2136dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label,
2137 struct REGEX_ITERNAL_State *start, 2137 struct REGEX_INTERNAL_State *start,
2138 struct REGEX_ITERNAL_State *s) 2138 struct REGEX_INTERNAL_State *s)
2139{ 2139{
2140 struct REGEX_ITERNAL_Strided_Context *ctx = cls; 2140 struct REGEX_INTERNAL_Strided_Context *ctx = cls;
2141 struct REGEX_ITERNAL_Transition *t; 2141 struct REGEX_INTERNAL_Transition *t;
2142 char *new_label; 2142 char *new_label;
2143 2143
2144 if (depth == ctx->stride) 2144 if (depth == ctx->stride)
2145 { 2145 {
2146 t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); 2146 t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
2147 t->label = GNUNET_strdup (label); 2147 t->label = GNUNET_strdup (label);
2148 t->to_state = s; 2148 t->to_state = s;
2149 t->from_state = start; 2149 t->from_state = start;
@@ -2184,7 +2184,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label,
2184 */ 2184 */
2185void 2185void
2186dfa_add_multi_strides (void *cls, const unsigned int count, 2186dfa_add_multi_strides (void *cls, const unsigned int count,
2187 struct REGEX_ITERNAL_State *s) 2187 struct REGEX_INTERNAL_State *s)
2188{ 2188{
2189 dfa_add_multi_strides_helper (cls, 0, NULL, s, s); 2189 dfa_add_multi_strides_helper (cls, 0, NULL, s, s);
2190} 2190}
@@ -2198,19 +2198,19 @@ dfa_add_multi_strides (void *cls, const unsigned int count,
2198 * @param stride_len length of the strides. 2198 * @param stride_len length of the strides.
2199 */ 2199 */
2200void 2200void
2201REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx, 2201REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx,
2202 struct REGEX_ITERNAL_Automaton *dfa, 2202 struct REGEX_INTERNAL_Automaton *dfa,
2203 const unsigned int stride_len) 2203 const unsigned int stride_len)
2204{ 2204{
2205 struct REGEX_ITERNAL_Strided_Context ctx = { stride_len, NULL, NULL }; 2205 struct REGEX_INTERNAL_Strided_Context ctx = { stride_len, NULL, NULL };
2206 struct REGEX_ITERNAL_Transition *t; 2206 struct REGEX_INTERNAL_Transition *t;
2207 struct REGEX_ITERNAL_Transition *t_next; 2207 struct REGEX_INTERNAL_Transition *t_next;
2208 2208
2209 if (1 > stride_len || GNUNET_YES == dfa->is_multistrided) 2209 if (1 > stride_len || GNUNET_YES == dfa->is_multistrided)
2210 return; 2210 return;
2211 2211
2212 /* Compute the new transitions of given stride_len */ 2212 /* Compute the new transitions of given stride_len */
2213 REGEX_ITERNAL_automaton_traverse (dfa, dfa->start, NULL, NULL, 2213 REGEX_INTERNAL_automaton_traverse (dfa, dfa->start, NULL, NULL,
2214 &dfa_add_multi_strides, &ctx); 2214 &dfa_add_multi_strides, &ctx);
2215 2215
2216 /* Add all the new transitions to the automaton. */ 2216 /* Add all the new transitions to the automaton. */
@@ -2241,14 +2241,14 @@ REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx,
2241 * @param transitions_tail transitions DLL. 2241 * @param transitions_tail transitions DLL.
2242 */ 2242 */
2243void 2243void
2244dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa, 2244dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa,
2245 struct REGEX_ITERNAL_State *start, 2245 struct REGEX_INTERNAL_State *start,
2246 struct REGEX_ITERNAL_State *cur, char *label, 2246 struct REGEX_INTERNAL_State *cur, char *label,
2247 unsigned int max_len, 2247 unsigned int max_len,
2248 struct REGEX_ITERNAL_Transition **transitions_head, 2248 struct REGEX_INTERNAL_Transition **transitions_head,
2249 struct REGEX_ITERNAL_Transition **transitions_tail) 2249 struct REGEX_INTERNAL_Transition **transitions_tail)
2250{ 2250{
2251 struct REGEX_ITERNAL_Transition *t; 2251 struct REGEX_INTERNAL_Transition *t;
2252 char *new_label; 2252 char *new_label;
2253 2253
2254 2254
@@ -2258,7 +2258,7 @@ dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa,
2258 max_len == strlen (label)) || 2258 max_len == strlen (label)) ||
2259 (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) 2259 (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label))))
2260 { 2260 {
2261 t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); 2261 t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
2262 t->label = GNUNET_strdup (label); 2262 t->label = GNUNET_strdup (label);
2263 t->to_state = cur; 2263 t->to_state = cur;
2264 t->from_state = start; 2264 t->from_state = start;
@@ -2306,15 +2306,15 @@ dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa,
2306 * @param max_len maximal length of the compressed paths. 2306 * @param max_len maximal length of the compressed paths.
2307 */ 2307 */
2308static void 2308static void
2309dfa_compress_paths (struct REGEX_ITERNAL_Context *regex_ctx, 2309dfa_compress_paths (struct REGEX_INTERNAL_Context *regex_ctx,
2310 struct REGEX_ITERNAL_Automaton *dfa, unsigned int max_len) 2310 struct REGEX_INTERNAL_Automaton *dfa, unsigned int max_len)
2311{ 2311{
2312 struct REGEX_ITERNAL_State *s; 2312 struct REGEX_INTERNAL_State *s;
2313 struct REGEX_ITERNAL_State *s_next; 2313 struct REGEX_INTERNAL_State *s_next;
2314 struct REGEX_ITERNAL_Transition *t; 2314 struct REGEX_INTERNAL_Transition *t;
2315 struct REGEX_ITERNAL_Transition *t_next; 2315 struct REGEX_INTERNAL_Transition *t_next;
2316 struct REGEX_ITERNAL_Transition *transitions_head = NULL; 2316 struct REGEX_INTERNAL_Transition *transitions_head = NULL;
2317 struct REGEX_ITERNAL_Transition *transitions_tail = NULL; 2317 struct REGEX_INTERNAL_Transition *transitions_tail = NULL;
2318 2318
2319 if (NULL == dfa) 2319 if (NULL == dfa)
2320 return; 2320 return;
@@ -2369,13 +2369,13 @@ dfa_compress_paths (struct REGEX_ITERNAL_Context *regex_ctx,
2369 * 2369 *
2370 * @return new NFA fragment 2370 * @return new NFA fragment
2371 */ 2371 */
2372static struct REGEX_ITERNAL_Automaton * 2372static struct REGEX_INTERNAL_Automaton *
2373nfa_fragment_create (struct REGEX_ITERNAL_State *start, 2373nfa_fragment_create (struct REGEX_INTERNAL_State *start,
2374 struct REGEX_ITERNAL_State *end) 2374 struct REGEX_INTERNAL_State *end)
2375{ 2375{
2376 struct REGEX_ITERNAL_Automaton *n; 2376 struct REGEX_INTERNAL_Automaton *n;
2377 2377
2378 n = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton)); 2378 n = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton));
2379 2379
2380 n->type = NFA; 2380 n->type = NFA;
2381 n->start = NULL; 2381 n->start = NULL;
@@ -2405,11 +2405,11 @@ nfa_fragment_create (struct REGEX_ITERNAL_State *start,
2405 * @param states_tail tail of the DLL of states 2405 * @param states_tail tail of the DLL of states
2406 */ 2406 */
2407static void 2407static void
2408nfa_add_states (struct REGEX_ITERNAL_Automaton *n, 2408nfa_add_states (struct REGEX_INTERNAL_Automaton *n,
2409 struct REGEX_ITERNAL_State *states_head, 2409 struct REGEX_INTERNAL_State *states_head,
2410 struct REGEX_ITERNAL_State *states_tail) 2410 struct REGEX_INTERNAL_State *states_tail)
2411{ 2411{
2412 struct REGEX_ITERNAL_State *s; 2412 struct REGEX_INTERNAL_State *s;
2413 2413
2414 if (NULL == n || NULL == states_head) 2414 if (NULL == n || NULL == states_head)
2415 { 2415 {
@@ -2443,12 +2443,12 @@ nfa_add_states (struct REGEX_ITERNAL_Automaton *n,
2443 * 2443 *
2444 * @return new NFA state 2444 * @return new NFA state
2445 */ 2445 */
2446static struct REGEX_ITERNAL_State * 2446static struct REGEX_INTERNAL_State *
2447nfa_state_create (struct REGEX_ITERNAL_Context *ctx, int accepting) 2447nfa_state_create (struct REGEX_INTERNAL_Context *ctx, int accepting)
2448{ 2448{
2449 struct REGEX_ITERNAL_State *s; 2449 struct REGEX_INTERNAL_State *s;
2450 2450
2451 s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State)); 2451 s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State));
2452 s->id = ctx->state_id++; 2452 s->id = ctx->state_id++;
2453 s->accepting = accepting; 2453 s->accepting = accepting;
2454 s->marked = GNUNET_NO; 2454 s->marked = GNUNET_NO;
@@ -2473,18 +2473,18 @@ nfa_state_create (struct REGEX_ITERNAL_Context *ctx, int accepting)
2473 * pass NULL for epsilon transition 2473 * pass NULL for epsilon transition
2474 */ 2474 */
2475static void 2475static void
2476nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret, 2476nfa_closure_set_create (struct REGEX_INTERNAL_StateSet *ret,
2477 struct REGEX_ITERNAL_Automaton *nfa, 2477 struct REGEX_INTERNAL_Automaton *nfa,
2478 struct REGEX_ITERNAL_StateSet *states, const char *label) 2478 struct REGEX_INTERNAL_StateSet *states, const char *label)
2479{ 2479{
2480 struct REGEX_ITERNAL_State *s; 2480 struct REGEX_INTERNAL_State *s;
2481 unsigned int i; 2481 unsigned int i;
2482 struct REGEX_ITERNAL_StateSet_MDLL cls_stack; 2482 struct REGEX_INTERNAL_StateSet_MDLL cls_stack;
2483 struct REGEX_ITERNAL_State *clsstate; 2483 struct REGEX_INTERNAL_State *clsstate;
2484 struct REGEX_ITERNAL_State *currentstate; 2484 struct REGEX_INTERNAL_State *currentstate;
2485 struct REGEX_ITERNAL_Transition *ctran; 2485 struct REGEX_INTERNAL_Transition *ctran;
2486 2486
2487 memset (ret, 0, sizeof (struct REGEX_ITERNAL_StateSet)); 2487 memset (ret, 0, sizeof (struct REGEX_INTERNAL_StateSet));
2488 if (NULL == states) 2488 if (NULL == states)
2489 return; 2489 return;
2490 2490
@@ -2528,7 +2528,7 @@ nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret,
2528 ret->states[i]->contained = 0; 2528 ret->states[i]->contained = 0;
2529 2529
2530 if (ret->off > 1) 2530 if (ret->off > 1)
2531 qsort (ret->states, ret->off, sizeof (struct REGEX_ITERNAL_State *), 2531 qsort (ret->states, ret->off, sizeof (struct REGEX_INTERNAL_State *),
2532 &state_compare); 2532 &state_compare);
2533} 2533}
2534 2534
@@ -2539,11 +2539,11 @@ nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret,
2539 * @param ctx context 2539 * @param ctx context
2540 */ 2540 */
2541static void 2541static void
2542nfa_add_concatenation (struct REGEX_ITERNAL_Context *ctx) 2542nfa_add_concatenation (struct REGEX_INTERNAL_Context *ctx)
2543{ 2543{
2544 struct REGEX_ITERNAL_Automaton *a; 2544 struct REGEX_INTERNAL_Automaton *a;
2545 struct REGEX_ITERNAL_Automaton *b; 2545 struct REGEX_INTERNAL_Automaton *b;
2546 struct REGEX_ITERNAL_Automaton *new_nfa; 2546 struct REGEX_INTERNAL_Automaton *new_nfa;
2547 2547
2548 b = ctx->stack_tail; 2548 b = ctx->stack_tail;
2549 GNUNET_assert (NULL != b); 2549 GNUNET_assert (NULL != b);
@@ -2575,12 +2575,12 @@ nfa_add_concatenation (struct REGEX_ITERNAL_Context *ctx)
2575 * @param ctx context 2575 * @param ctx context
2576 */ 2576 */
2577static void 2577static void
2578nfa_add_star_op (struct REGEX_ITERNAL_Context *ctx) 2578nfa_add_star_op (struct REGEX_INTERNAL_Context *ctx)
2579{ 2579{
2580 struct REGEX_ITERNAL_Automaton *a; 2580 struct REGEX_INTERNAL_Automaton *a;
2581 struct REGEX_ITERNAL_Automaton *new_nfa; 2581 struct REGEX_INTERNAL_Automaton *new_nfa;
2582 struct REGEX_ITERNAL_State *start; 2582 struct REGEX_INTERNAL_State *start;
2583 struct REGEX_ITERNAL_State *end; 2583 struct REGEX_INTERNAL_State *end;
2584 2584
2585 a = ctx->stack_tail; 2585 a = ctx->stack_tail;
2586 2586
@@ -2618,9 +2618,9 @@ nfa_add_star_op (struct REGEX_ITERNAL_Context *ctx)
2618 * @param ctx context 2618 * @param ctx context
2619 */ 2619 */
2620static void 2620static void
2621nfa_add_plus_op (struct REGEX_ITERNAL_Context *ctx) 2621nfa_add_plus_op (struct REGEX_INTERNAL_Context *ctx)
2622{ 2622{
2623 struct REGEX_ITERNAL_Automaton *a; 2623 struct REGEX_INTERNAL_Automaton *a;
2624 2624
2625 a = ctx->stack_tail; 2625 a = ctx->stack_tail;
2626 2626
@@ -2645,12 +2645,12 @@ nfa_add_plus_op (struct REGEX_ITERNAL_Context *ctx)
2645 * @param ctx context 2645 * @param ctx context
2646 */ 2646 */
2647static void 2647static void
2648nfa_add_question_op (struct REGEX_ITERNAL_Context *ctx) 2648nfa_add_question_op (struct REGEX_INTERNAL_Context *ctx)
2649{ 2649{
2650 struct REGEX_ITERNAL_Automaton *a; 2650 struct REGEX_INTERNAL_Automaton *a;
2651 struct REGEX_ITERNAL_Automaton *new_nfa; 2651 struct REGEX_INTERNAL_Automaton *new_nfa;
2652 struct REGEX_ITERNAL_State *start; 2652 struct REGEX_INTERNAL_State *start;
2653 struct REGEX_ITERNAL_State *end; 2653 struct REGEX_INTERNAL_State *end;
2654 2654
2655 a = ctx->stack_tail; 2655 a = ctx->stack_tail;
2656 2656
@@ -2686,13 +2686,13 @@ nfa_add_question_op (struct REGEX_ITERNAL_Context *ctx)
2686 * @param ctx context 2686 * @param ctx context
2687 */ 2687 */
2688static void 2688static void
2689nfa_add_alternation (struct REGEX_ITERNAL_Context *ctx) 2689nfa_add_alternation (struct REGEX_INTERNAL_Context *ctx)
2690{ 2690{
2691 struct REGEX_ITERNAL_Automaton *a; 2691 struct REGEX_INTERNAL_Automaton *a;
2692 struct REGEX_ITERNAL_Automaton *b; 2692 struct REGEX_INTERNAL_Automaton *b;
2693 struct REGEX_ITERNAL_Automaton *new_nfa; 2693 struct REGEX_INTERNAL_Automaton *new_nfa;
2694 struct REGEX_ITERNAL_State *start; 2694 struct REGEX_INTERNAL_State *start;
2695 struct REGEX_ITERNAL_State *end; 2695 struct REGEX_INTERNAL_State *end;
2696 2696
2697 b = ctx->stack_tail; 2697 b = ctx->stack_tail;
2698 GNUNET_assert (NULL != b); 2698 GNUNET_assert (NULL != b);
@@ -2730,11 +2730,11 @@ nfa_add_alternation (struct REGEX_ITERNAL_Context *ctx)
2730 * @param label label for nfa transition 2730 * @param label label for nfa transition
2731 */ 2731 */
2732static void 2732static void
2733nfa_add_label (struct REGEX_ITERNAL_Context *ctx, const char *label) 2733nfa_add_label (struct REGEX_INTERNAL_Context *ctx, const char *label)
2734{ 2734{
2735 struct REGEX_ITERNAL_Automaton *n; 2735 struct REGEX_INTERNAL_Automaton *n;
2736 struct REGEX_ITERNAL_State *start; 2736 struct REGEX_INTERNAL_State *start;
2737 struct REGEX_ITERNAL_State *end; 2737 struct REGEX_INTERNAL_State *end;
2738 2738
2739 GNUNET_assert (NULL != ctx); 2739 GNUNET_assert (NULL != ctx);
2740 2740
@@ -2753,7 +2753,7 @@ nfa_add_label (struct REGEX_ITERNAL_Context *ctx, const char *label)
2753 * @param ctx context 2753 * @param ctx context
2754 */ 2754 */
2755static void 2755static void
2756REGEX_ITERNAL_context_init (struct REGEX_ITERNAL_Context *ctx) 2756REGEX_INTERNAL_context_init (struct REGEX_INTERNAL_Context *ctx)
2757{ 2757{
2758 if (NULL == ctx) 2758 if (NULL == ctx)
2759 { 2759 {
@@ -2773,13 +2773,13 @@ REGEX_ITERNAL_context_init (struct REGEX_ITERNAL_Context *ctx)
2773 * @param regex regular expression string 2773 * @param regex regular expression string
2774 * @param len length of the string 2774 * @param len length of the string
2775 * 2775 *
2776 * @return NFA, needs to be freed using REGEX_ITERNAL_destroy_automaton 2776 * @return NFA, needs to be freed using REGEX_INTERNAL_destroy_automaton
2777 */ 2777 */
2778struct REGEX_ITERNAL_Automaton * 2778struct REGEX_INTERNAL_Automaton *
2779REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len) 2779REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len)
2780{ 2780{
2781 struct REGEX_ITERNAL_Context ctx; 2781 struct REGEX_INTERNAL_Context ctx;
2782 struct REGEX_ITERNAL_Automaton *nfa; 2782 struct REGEX_INTERNAL_Automaton *nfa;
2783 const char *regexp; 2783 const char *regexp;
2784 char curlabel[2]; 2784 char curlabel[2];
2785 char *error_msg; 2785 char *error_msg;
@@ -2801,7 +2801,7 @@ REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len)
2801 2801
2802 return NULL; 2802 return NULL;
2803 } 2803 }
2804 REGEX_ITERNAL_context_init (&ctx); 2804 REGEX_INTERNAL_context_init (&ctx);
2805 2805
2806 regexp = regex; 2806 regexp = regex;
2807 curlabel[1] = '\0'; 2807 curlabel[1] = '\0';
@@ -2924,7 +2924,7 @@ REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len)
2924 nfa->regex = GNUNET_strdup (regex); 2924 nfa->regex = GNUNET_strdup (regex);
2925 2925
2926 /* create depth-first numbering of the states for pretty printing */ 2926 /* create depth-first numbering of the states for pretty printing */
2927 REGEX_ITERNAL_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); 2927 REGEX_INTERNAL_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL);
2928 2928
2929 /* No multistriding added so far */ 2929 /* No multistriding added so far */
2930 nfa->is_multistrided = GNUNET_NO; 2930 nfa->is_multistrided = GNUNET_NO;
@@ -2941,7 +2941,7 @@ error:
2941 while (NULL != (nfa = ctx.stack_head)) 2941 while (NULL != (nfa = ctx.stack_head))
2942 { 2942 {
2943 GNUNET_CONTAINER_DLL_remove (ctx.stack_head, ctx.stack_tail, nfa); 2943 GNUNET_CONTAINER_DLL_remove (ctx.stack_head, ctx.stack_tail, nfa);
2944 REGEX_ITERNAL_automaton_destroy (nfa); 2944 REGEX_INTERNAL_automaton_destroy (nfa);
2945 } 2945 }
2946 2946
2947 return NULL; 2947 return NULL;
@@ -2958,17 +2958,17 @@ error:
2958 * for starting. 2958 * for starting.
2959 */ 2959 */
2960static void 2960static void
2961construct_dfa_states (struct REGEX_ITERNAL_Context *ctx, 2961construct_dfa_states (struct REGEX_INTERNAL_Context *ctx,
2962 struct REGEX_ITERNAL_Automaton *nfa, 2962 struct REGEX_INTERNAL_Automaton *nfa,
2963 struct REGEX_ITERNAL_Automaton *dfa, 2963 struct REGEX_INTERNAL_Automaton *dfa,
2964 struct REGEX_ITERNAL_State *dfa_state) 2964 struct REGEX_INTERNAL_State *dfa_state)
2965{ 2965{
2966 struct REGEX_ITERNAL_Transition *ctran; 2966 struct REGEX_INTERNAL_Transition *ctran;
2967 struct REGEX_ITERNAL_State *new_dfa_state; 2967 struct REGEX_INTERNAL_State *new_dfa_state;
2968 struct REGEX_ITERNAL_State *state_contains; 2968 struct REGEX_INTERNAL_State *state_contains;
2969 struct REGEX_ITERNAL_State *state_iter; 2969 struct REGEX_INTERNAL_State *state_iter;
2970 struct REGEX_ITERNAL_StateSet tmp; 2970 struct REGEX_INTERNAL_StateSet tmp;
2971 struct REGEX_ITERNAL_StateSet nfa_set; 2971 struct REGEX_INTERNAL_StateSet nfa_set;
2972 2972
2973 for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next) 2973 for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next)
2974 { 2974 {
@@ -3020,23 +3020,23 @@ construct_dfa_states (struct REGEX_ITERNAL_Context *ctx,
3020 * @param max_path_len limit the path compression length to the 3020 * @param max_path_len limit the path compression length to the
3021 * given value. If set to 1, no path compression is applied. Set to 0 for 3021 * given value. If set to 1, no path compression is applied. Set to 0 for
3022 * maximal possible path compression (generally not desireable). 3022 * maximal possible path compression (generally not desireable).
3023 * @return DFA, needs to be freed using REGEX_ITERNAL_automaton_destroy. 3023 * @return DFA, needs to be freed using REGEX_INTERNAL_automaton_destroy.
3024 */ 3024 */
3025struct REGEX_ITERNAL_Automaton * 3025struct REGEX_INTERNAL_Automaton *
3026REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len, 3026REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len,
3027 unsigned int max_path_len) 3027 unsigned int max_path_len)
3028{ 3028{
3029 struct REGEX_ITERNAL_Context ctx; 3029 struct REGEX_INTERNAL_Context ctx;
3030 struct REGEX_ITERNAL_Automaton *dfa; 3030 struct REGEX_INTERNAL_Automaton *dfa;
3031 struct REGEX_ITERNAL_Automaton *nfa; 3031 struct REGEX_INTERNAL_Automaton *nfa;
3032 struct REGEX_ITERNAL_StateSet nfa_start_eps_cls; 3032 struct REGEX_INTERNAL_StateSet nfa_start_eps_cls;
3033 struct REGEX_ITERNAL_StateSet singleton_set; 3033 struct REGEX_INTERNAL_StateSet singleton_set;
3034 3034
3035 REGEX_ITERNAL_context_init (&ctx); 3035 REGEX_INTERNAL_context_init (&ctx);
3036 3036
3037 /* Create NFA */ 3037 /* Create NFA */
3038 // fprintf (stderr, "N"); 3038 // fprintf (stderr, "N");
3039 nfa = REGEX_ITERNAL_construct_nfa (regex, len); 3039 nfa = REGEX_INTERNAL_construct_nfa (regex, len);
3040 3040
3041 if (NULL == nfa) 3041 if (NULL == nfa)
3042 { 3042 {
@@ -3045,12 +3045,12 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
3045 return NULL; 3045 return NULL;
3046 } 3046 }
3047 3047
3048 dfa = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton)); 3048 dfa = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton));
3049 dfa->type = DFA; 3049 dfa->type = DFA;
3050 dfa->regex = GNUNET_strdup (regex); 3050 dfa->regex = GNUNET_strdup (regex);
3051 3051
3052 /* Create DFA start state from epsilon closure */ 3052 /* Create DFA start state from epsilon closure */
3053 memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet)); 3053 memset (&singleton_set, 0, sizeof (struct REGEX_INTERNAL_StateSet));
3054 state_set_append (&singleton_set, nfa->start); 3054 state_set_append (&singleton_set, nfa->start);
3055 nfa_closure_set_create (&nfa_start_eps_cls, nfa, &singleton_set, NULL); 3055 nfa_closure_set_create (&nfa_start_eps_cls, nfa, &singleton_set, NULL);
3056 state_set_clear (&singleton_set); 3056 state_set_clear (&singleton_set);
@@ -3059,20 +3059,20 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
3059 3059
3060 // fprintf (stderr, "D"); 3060 // fprintf (stderr, "D");
3061 construct_dfa_states (&ctx, nfa, dfa, dfa->start); 3061 construct_dfa_states (&ctx, nfa, dfa, dfa->start);
3062 REGEX_ITERNAL_automaton_destroy (nfa); 3062 REGEX_INTERNAL_automaton_destroy (nfa);
3063 3063
3064 /* Minimize DFA */ 3064 /* Minimize DFA */
3065 // fprintf (stderr, "M"); 3065 // fprintf (stderr, "M");
3066 if (GNUNET_OK != dfa_minimize (&ctx, dfa)) 3066 if (GNUNET_OK != dfa_minimize (&ctx, dfa))
3067 { 3067 {
3068 REGEX_ITERNAL_automaton_destroy (dfa); 3068 REGEX_INTERNAL_automaton_destroy (dfa);
3069 return NULL; 3069 return NULL;
3070 } 3070 }
3071 3071
3072 /* Create proofs and hashes for all states */ 3072 /* Create proofs and hashes for all states */
3073 if (GNUNET_OK != automaton_create_proofs (dfa)) 3073 if (GNUNET_OK != automaton_create_proofs (dfa))
3074 { 3074 {
3075 REGEX_ITERNAL_automaton_destroy (dfa); 3075 REGEX_INTERNAL_automaton_destroy (dfa);
3076 return NULL; 3076 return NULL;
3077 } 3077 }
3078 3078
@@ -3085,16 +3085,16 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
3085 3085
3086 3086
3087/** 3087/**
3088 * Free the memory allocated by constructing the REGEX_ITERNAL_Automaton data 3088 * Free the memory allocated by constructing the REGEX_INTERNAL_Automaton data
3089 * structure. 3089 * structure.
3090 * 3090 *
3091 * @param a automaton to be destroyed 3091 * @param a automaton to be destroyed
3092 */ 3092 */
3093void 3093void
3094REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a) 3094REGEX_INTERNAL_automaton_destroy (struct REGEX_INTERNAL_Automaton *a)
3095{ 3095{
3096 struct REGEX_ITERNAL_State *s; 3096 struct REGEX_INTERNAL_State *s;
3097 struct REGEX_ITERNAL_State *next_state; 3097 struct REGEX_INTERNAL_State *next_state;
3098 3098
3099 if (NULL == a) 3099 if (NULL == a)
3100 return; 3100 return;
@@ -3122,10 +3122,10 @@ REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a)
3122 * @return 0 if string matches, non 0 otherwise 3122 * @return 0 if string matches, non 0 otherwise
3123 */ 3123 */
3124static int 3124static int
3125evaluate_dfa (struct REGEX_ITERNAL_Automaton *a, const char *string) 3125evaluate_dfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
3126{ 3126{
3127 const char *strp; 3127 const char *strp;
3128 struct REGEX_ITERNAL_State *s; 3128 struct REGEX_INTERNAL_State *s;
3129 unsigned int step_len; 3129 unsigned int step_len;
3130 3130
3131 if (DFA != a->type) 3131 if (DFA != a->type)
@@ -3165,14 +3165,14 @@ evaluate_dfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
3165 * @return 0 if string matches, non 0 otherwise 3165 * @return 0 if string matches, non 0 otherwise
3166 */ 3166 */
3167static int 3167static int
3168evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string) 3168evaluate_nfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
3169{ 3169{
3170 const char *strp; 3170 const char *strp;
3171 char str[2]; 3171 char str[2];
3172 struct REGEX_ITERNAL_State *s; 3172 struct REGEX_INTERNAL_State *s;
3173 struct REGEX_ITERNAL_StateSet sset; 3173 struct REGEX_INTERNAL_StateSet sset;
3174 struct REGEX_ITERNAL_StateSet new_sset; 3174 struct REGEX_INTERNAL_StateSet new_sset;
3175 struct REGEX_ITERNAL_StateSet singleton_set; 3175 struct REGEX_INTERNAL_StateSet singleton_set;
3176 unsigned int i; 3176 unsigned int i;
3177 int result; 3177 int result;
3178 3178
@@ -3188,7 +3188,7 @@ evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
3188 return 0; 3188 return 0;
3189 3189
3190 result = 1; 3190 result = 1;
3191 memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet)); 3191 memset (&singleton_set, 0, sizeof (struct REGEX_INTERNAL_StateSet));
3192 state_set_append (&singleton_set, a->start); 3192 state_set_append (&singleton_set, a->start);
3193 nfa_closure_set_create (&sset, a, &singleton_set, NULL); 3193 nfa_closure_set_create (&sset, a, &singleton_set, NULL);
3194 state_set_clear (&singleton_set); 3194 state_set_clear (&singleton_set);
@@ -3227,7 +3227,7 @@ evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
3227 * @return 0 if string matches, non 0 otherwise 3227 * @return 0 if string matches, non 0 otherwise
3228 */ 3228 */
3229int 3229int
3230REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, const char *string) 3230REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string)
3231{ 3231{
3232 int result; 3232 int result;
3233 3233
@@ -3262,7 +3262,7 @@ REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, const char *string)
3262 * @return 3262 * @return
3263 */ 3263 */
3264const char * 3264const char *
3265REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a) 3265REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a)
3266{ 3266{
3267 if (NULL == a) 3267 if (NULL == a)
3268 return NULL; 3268 return NULL;
@@ -3279,10 +3279,10 @@ REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a)
3279 * @return number of transitions in the given automaton. 3279 * @return number of transitions in the given automaton.
3280 */ 3280 */
3281unsigned int 3281unsigned int
3282REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a) 3282REGEX_INTERNAL_get_transition_count (struct REGEX_INTERNAL_Automaton *a)
3283{ 3283{
3284 unsigned int t_count; 3284 unsigned int t_count;
3285 struct REGEX_ITERNAL_State *s; 3285 struct REGEX_INTERNAL_State *s;
3286 3286
3287 if (NULL == a) 3287 if (NULL == a)
3288 return 0; 3288 return 0;
@@ -3307,7 +3307,7 @@ REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a)
3307 * to construct the key 3307 * to construct the key
3308 */ 3308 */
3309size_t 3309size_t
3310REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len, 3310REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len,
3311 struct GNUNET_HashCode * key) 3311 struct GNUNET_HashCode * key)
3312{ 3312{
3313 unsigned int size; 3313 unsigned int size;
@@ -3337,7 +3337,7 @@ REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len,
3337 * @return GNUNET_OK if the proof is valid for the given key. 3337 * @return GNUNET_OK if the proof is valid for the given key.
3338 */ 3338 */
3339int 3339int
3340REGEX_ITERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key) 3340REGEX_INTERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key)
3341{ 3341{
3342 struct GNUNET_HashCode key_check; 3342 struct GNUNET_HashCode key_check;
3343 3343
@@ -3365,15 +3365,15 @@ REGEX_ITERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key)
3365 */ 3365 */
3366static void 3366static void
3367iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, 3367iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
3368 char *consumed_string, struct REGEX_ITERNAL_State *state, 3368 char *consumed_string, struct REGEX_INTERNAL_State *state,
3369 REGEX_ITERNAL_KeyIterator iterator, void *iterator_cls) 3369 REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
3370{ 3370{
3371 unsigned int i; 3371 unsigned int i;
3372 char *temp; 3372 char *temp;
3373 struct REGEX_ITERNAL_Transition *t; 3373 struct REGEX_INTERNAL_Transition *t;
3374 unsigned int num_edges = state->transition_count; 3374 unsigned int num_edges = state->transition_count;
3375 struct REGEX_ITERNAL_Edge edges[num_edges]; 3375 struct REGEX_INTERNAL_Edge edges[num_edges];
3376 struct REGEX_ITERNAL_Edge edge[1]; 3376 struct REGEX_INTERNAL_Edge edge[1];
3377 struct GNUNET_HashCode hash; 3377 struct GNUNET_HashCode hash;
3378 struct GNUNET_HashCode hash_new; 3378 struct GNUNET_HashCode hash_new;
3379 3379
@@ -3455,15 +3455,15 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
3455 * @param iterator_cls closure. 3455 * @param iterator_cls closure.
3456 */ 3456 */
3457void 3457void
3458REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a, 3458REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a,
3459 REGEX_ITERNAL_KeyIterator iterator, 3459 REGEX_INTERNAL_KeyIterator iterator,
3460 void *iterator_cls) 3460 void *iterator_cls)
3461{ 3461{
3462 struct REGEX_ITERNAL_State *s; 3462 struct REGEX_INTERNAL_State *s;
3463 3463
3464 for (s = a->states_head; NULL != s; s = s->next) 3464 for (s = a->states_head; NULL != s; s = s->next)
3465 { 3465 {
3466 struct REGEX_ITERNAL_Edge edges[s->transition_count]; 3466 struct REGEX_INTERNAL_Edge edges[s->transition_count];
3467 unsigned int num_edges; 3467 unsigned int num_edges;
3468 3468
3469 num_edges = state_get_edges (s, edges); 3469 num_edges = state_get_edges (s, edges);