aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_internal.c
diff options
context:
space:
mode:
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 e668351346..6fda695a7b 100644
--- a/src/regex/regex_internal.c
+++ b/src/regex/regex_internal.c
@@ -39,17 +39,17 @@
/**
* Set of states using MDLL API.
*/
-struct REGEX_ITERNAL_StateSet_MDLL
+struct REGEX_INTERNAL_StateSet_MDLL
{
/**
* MDLL of states.
*/
- struct REGEX_ITERNAL_State *head;
+ struct REGEX_INTERNAL_State *head;
/**
* MDLL of states.
*/
- struct REGEX_ITERNAL_State *tail;
+ struct REGEX_INTERNAL_State *tail;
/**
* Length of the MDLL.
@@ -65,8 +65,8 @@ struct REGEX_ITERNAL_StateSet_MDLL
* @param state state to be appended
*/
static void
-state_set_append (struct REGEX_ITERNAL_StateSet *set,
- struct REGEX_ITERNAL_State *state)
+state_set_append (struct REGEX_INTERNAL_StateSet *set,
+ struct REGEX_INTERNAL_State *state)
{
if (set->off == set->size)
GNUNET_array_grow (set->states, set->size, set->size * 2 + 4);
@@ -104,12 +104,12 @@ nullstrcmp (const char *str1, const char *str2)
* @param to_state state to where the transition should point to
*/
static void
-state_add_transition (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_State *from_state, const char *label,
- struct REGEX_ITERNAL_State *to_state)
+state_add_transition (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_State *from_state, const char *label,
+ struct REGEX_INTERNAL_State *to_state)
{
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_Transition *oth;
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *oth;
if (NULL == from_state)
{
@@ -132,7 +132,7 @@ state_add_transition (struct REGEX_ITERNAL_Context *ctx,
break;
}
- t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition));
+ t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
if (NULL != ctx)
t->id = ctx->transition_id++;
if (NULL != label)
@@ -156,8 +156,8 @@ state_add_transition (struct REGEX_ITERNAL_Context *ctx,
* @param transition transition that should be removed from state 'state'.
*/
static void
-state_remove_transition (struct REGEX_ITERNAL_State *state,
- struct REGEX_ITERNAL_Transition *transition)
+state_remove_transition (struct REGEX_INTERNAL_State *state,
+ struct REGEX_INTERNAL_Transition *transition)
{
if (NULL == state || NULL == transition)
return;
@@ -188,8 +188,8 @@ state_remove_transition (struct REGEX_ITERNAL_State *state,
static int
state_compare (const void *a, const void *b)
{
- struct REGEX_ITERNAL_State **s1 = (struct REGEX_ITERNAL_State **) a;
- struct REGEX_ITERNAL_State **s2 = (struct REGEX_ITERNAL_State **) b;
+ struct REGEX_INTERNAL_State **s1 = (struct REGEX_INTERNAL_State **) a;
+ struct REGEX_INTERNAL_State **s2 = (struct REGEX_INTERNAL_State **) b;
return (*s1)->id - (*s2)->id;
}
@@ -205,9 +205,9 @@ state_compare (const void *a, const void *b)
* @return number of edges.
*/
static unsigned int
-state_get_edges (struct REGEX_ITERNAL_State *s, struct REGEX_ITERNAL_Edge *edges)
+state_get_edges (struct REGEX_INTERNAL_State *s, struct REGEX_INTERNAL_Edge *edges)
{
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t;
unsigned int count;
if (NULL == s)
@@ -237,8 +237,8 @@ state_get_edges (struct REGEX_ITERNAL_State *s, struct REGEX_ITERNAL_Edge *edges
* @return 0 if the sets are equal, otherwise non-zero
*/
static int
-state_set_compare (struct REGEX_ITERNAL_StateSet *sset1,
- struct REGEX_ITERNAL_StateSet *sset2)
+state_set_compare (struct REGEX_INTERNAL_StateSet *sset1,
+ struct REGEX_INTERNAL_StateSet *sset2)
{
int result;
unsigned int i;
@@ -264,7 +264,7 @@ state_set_compare (struct REGEX_ITERNAL_StateSet *sset1,
* @param set set to be cleared
*/
static void
-state_set_clear (struct REGEX_ITERNAL_StateSet *set)
+state_set_clear (struct REGEX_INTERNAL_StateSet *set)
{
GNUNET_array_grow (set->states, set->size, 0);
set->off = 0;
@@ -278,7 +278,7 @@ state_set_clear (struct REGEX_ITERNAL_StateSet *set)
* @param a automaton to be cleared
*/
static void
-automaton_fragment_clear (struct REGEX_ITERNAL_Automaton *a)
+automaton_fragment_clear (struct REGEX_INTERNAL_Automaton *a)
{
if (NULL == a)
return;
@@ -298,10 +298,10 @@ automaton_fragment_clear (struct REGEX_ITERNAL_Automaton *a)
* @param s state that should be destroyed
*/
static void
-automaton_destroy_state (struct REGEX_ITERNAL_State *s)
+automaton_destroy_state (struct REGEX_INTERNAL_State *s)
{
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_Transition *next_t;
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *next_t;
if (NULL == s)
return;
@@ -328,12 +328,12 @@ automaton_destroy_state (struct REGEX_ITERNAL_State *s)
* @param s state to remove
*/
static void
-automaton_remove_state (struct REGEX_ITERNAL_Automaton *a,
- struct REGEX_ITERNAL_State *s)
+automaton_remove_state (struct REGEX_INTERNAL_Automaton *a,
+ struct REGEX_INTERNAL_State *s)
{
- struct REGEX_ITERNAL_State *s_check;
- struct REGEX_ITERNAL_Transition *t_check;
- struct REGEX_ITERNAL_Transition *t_check_next;
+ struct REGEX_INTERNAL_State *s_check;
+ struct REGEX_INTERNAL_Transition *t_check;
+ struct REGEX_INTERNAL_Transition *t_check_next;
if (NULL == a || NULL == s)
return;
@@ -368,15 +368,15 @@ automaton_remove_state (struct REGEX_ITERNAL_Automaton *a,
* @param s2 second state, will be destroyed
*/
static void
-automaton_merge_states (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_Automaton *a,
- struct REGEX_ITERNAL_State *s1,
- struct REGEX_ITERNAL_State *s2)
-{
- struct REGEX_ITERNAL_State *s_check;
- struct REGEX_ITERNAL_Transition *t_check;
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_Transition *t_next;
+automaton_merge_states (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_Automaton *a,
+ struct REGEX_INTERNAL_State *s1,
+ struct REGEX_INTERNAL_State *s2)
+{
+ struct REGEX_INTERNAL_State *s_check;
+ struct REGEX_INTERNAL_Transition *t_check;
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t_next;
int is_dup;
if (s1 == s2)
@@ -437,8 +437,8 @@ automaton_merge_states (struct REGEX_ITERNAL_Context *ctx,
* @param s state that should be added
*/
static void
-automaton_add_state (struct REGEX_ITERNAL_Automaton *a,
- struct REGEX_ITERNAL_State *s)
+automaton_add_state (struct REGEX_INTERNAL_Automaton *a,
+ struct REGEX_INTERNAL_State *s)
{
GNUNET_CONTAINER_DLL_insert (a->states_head, a->states_tail, s);
a->state_count++;
@@ -460,12 +460,12 @@ automaton_add_state (struct REGEX_ITERNAL_Automaton *a,
* @param action_cls closure for action.
*/
static void
-automaton_state_traverse (struct REGEX_ITERNAL_State *s, int *marks,
+automaton_state_traverse (struct REGEX_INTERNAL_State *s, int *marks,
unsigned int *count,
- REGEX_ITERNAL_traverse_check check, void *check_cls,
- REGEX_ITERNAL_traverse_action action, void *action_cls)
+ REGEX_INTERNAL_traverse_check check, void *check_cls,
+ REGEX_INTERNAL_traverse_action action, void *action_cls)
{
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t;
if (GNUNET_YES == marks[s->traversal_id])
return;
@@ -503,15 +503,15 @@ automaton_state_traverse (struct REGEX_ITERNAL_State *s, int *marks,
* @param action_cls closure for action
*/
void
-REGEX_ITERNAL_automaton_traverse (const struct REGEX_ITERNAL_Automaton *a,
- struct REGEX_ITERNAL_State *start,
- REGEX_ITERNAL_traverse_check check,
+REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a,
+ struct REGEX_INTERNAL_State *start,
+ REGEX_INTERNAL_traverse_check check,
void *check_cls,
- REGEX_ITERNAL_traverse_action action,
+ REGEX_INTERNAL_traverse_action action,
void *action_cls)
{
unsigned int count;
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
if (NULL == a || 0 == a->state_count)
return;
@@ -1156,7 +1156,7 @@ sb_strkcmp (const struct StringBuffer *str1,
/**
- * Helper function used as 'action' in 'REGEX_ITERNAL_automaton_traverse'
+ * Helper function used as 'action' in 'REGEX_INTERNAL_automaton_traverse'
* function to create the depth-first numbering of the states.
*
* @param cls states array.
@@ -1165,9 +1165,9 @@ sb_strkcmp (const struct StringBuffer *str1,
*/
static void
number_states (void *cls, const unsigned int count,
- struct REGEX_ITERNAL_State *s)
+ struct REGEX_INTERNAL_State *s)
{
- struct REGEX_ITERNAL_State **states = cls;
+ struct REGEX_INTERNAL_State **states = cls;
s->dfs_id = count;
if (NULL != states)
@@ -1604,16 +1604,16 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij,
* @param a automaton for which to assign proofs and hashes, must not be NULL
*/
static int
-automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a)
+automaton_create_proofs (struct REGEX_INTERNAL_Automaton *a)
{
unsigned int n = a->state_count;
- struct REGEX_ITERNAL_State *states[n];
+ struct REGEX_INTERNAL_State *states[n];
struct StringBuffer *R_last;
struct StringBuffer *R_cur;
struct StringBuffer R_cur_r;
struct StringBuffer R_cur_l;
struct StringBuffer *R_swap;
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t;
struct StringBuffer complete_regex;
unsigned int i;
unsigned int j;
@@ -1631,7 +1631,7 @@ automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a)
}
/* create depth-first numbering of the states, initializes 'state' */
- REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &number_states,
+ REGEX_INTERNAL_automaton_traverse (a, a->start, NULL, NULL, &number_states,
states);
for (i = 0; i < n; i++)
@@ -1763,18 +1763,18 @@ automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a)
*
* @return new DFA state
*/
-static struct REGEX_ITERNAL_State *
-dfa_state_create (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_StateSet *nfa_states)
+static struct REGEX_INTERNAL_State *
+dfa_state_create (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_StateSet *nfa_states)
{
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
char *pos;
size_t len;
- struct REGEX_ITERNAL_State *cstate;
- struct REGEX_ITERNAL_Transition *ctran;
+ struct REGEX_INTERNAL_State *cstate;
+ struct REGEX_INTERNAL_Transition *ctran;
unsigned int i;
- s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State));
+ s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State));
s->id = ctx->state_id++;
s->index = -1;
s->lowlink = -1;
@@ -1816,7 +1816,7 @@ dfa_state_create (struct REGEX_ITERNAL_Context *ctx,
pos[-1] = '}';
s->name = GNUNET_realloc (s->name, strlen (s->name) + 1);
- memset (nfa_states, 0, sizeof (struct REGEX_ITERNAL_StateSet));
+ memset (nfa_states, 0, sizeof (struct REGEX_INTERNAL_StateSet));
return s;
}
@@ -1835,10 +1835,10 @@ dfa_state_create (struct REGEX_ITERNAL_Context *ctx,
* @return length of the substring comsumed from 'str'
*/
static unsigned int
-dfa_move (struct REGEX_ITERNAL_State **s, const char *str)
+dfa_move (struct REGEX_INTERNAL_State **s, const char *str)
{
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_State *new_s;
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_State *new_s;
unsigned int len;
unsigned int max_len;
@@ -1876,7 +1876,7 @@ dfa_move (struct REGEX_ITERNAL_State **s, const char *str)
* @param s state where the marked attribute will be set to GNUNET_YES.
*/
static void
-mark_states (void *cls, const unsigned int count, struct REGEX_ITERNAL_State *s)
+mark_states (void *cls, const unsigned int count, struct REGEX_INTERNAL_State *s)
{
s->marked = GNUNET_YES;
}
@@ -1889,17 +1889,17 @@ mark_states (void *cls, const unsigned int count, struct REGEX_ITERNAL_State *s)
* @param a DFA automaton
*/
static void
-dfa_remove_unreachable_states (struct REGEX_ITERNAL_Automaton *a)
+dfa_remove_unreachable_states (struct REGEX_INTERNAL_Automaton *a)
{
- struct REGEX_ITERNAL_State *s;
- struct REGEX_ITERNAL_State *s_next;
+ struct REGEX_INTERNAL_State *s;
+ struct REGEX_INTERNAL_State *s_next;
/* 1. unmark all states */
for (s = a->states_head; NULL != s; s = s->next)
s->marked = GNUNET_NO;
/* 2. traverse dfa from start state and mark all visited states */
- REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL);
+ REGEX_INTERNAL_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL);
/* 3. delete all states that were not visited */
for (s = a->states_head; NULL != s; s = s_next)
@@ -1918,11 +1918,11 @@ dfa_remove_unreachable_states (struct REGEX_ITERNAL_Automaton *a)
* @param a DFA automaton
*/
static void
-dfa_remove_dead_states (struct REGEX_ITERNAL_Automaton *a)
+dfa_remove_dead_states (struct REGEX_INTERNAL_Automaton *a)
{
- struct REGEX_ITERNAL_State *s;
- struct REGEX_ITERNAL_State *s_next;
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_State *s;
+ struct REGEX_INTERNAL_State *s_next;
+ struct REGEX_INTERNAL_Transition *t;
int dead;
GNUNET_assert (DFA == a->type);
@@ -1961,16 +1961,16 @@ dfa_remove_dead_states (struct REGEX_ITERNAL_Automaton *a)
* @return GNUNET_OK on success
*/
static int
-dfa_merge_nondistinguishable_states (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_Automaton *a)
+dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_Automaton *a)
{
uint32_t *table;
- struct REGEX_ITERNAL_State *s1;
- struct REGEX_ITERNAL_State *s2;
- struct REGEX_ITERNAL_Transition *t1;
- struct REGEX_ITERNAL_Transition *t2;
- struct REGEX_ITERNAL_State *s1_next;
- struct REGEX_ITERNAL_State *s2_next;
+ struct REGEX_INTERNAL_State *s1;
+ struct REGEX_INTERNAL_State *s2;
+ struct REGEX_INTERNAL_Transition *t1;
+ struct REGEX_INTERNAL_Transition *t2;
+ struct REGEX_INTERNAL_State *s1_next;
+ struct REGEX_INTERNAL_State *s2_next;
int change;
unsigned int num_equal_edges;
unsigned int i;
@@ -2078,8 +2078,8 @@ dfa_merge_nondistinguishable_states (struct REGEX_ITERNAL_Context *ctx,
* @return GNUNET_OK on success
*/
static int
-dfa_minimize (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_Automaton *a)
+dfa_minimize (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_Automaton *a)
{
if (NULL == a)
return GNUNET_SYSERR;
@@ -2102,7 +2102,7 @@ dfa_minimize (struct REGEX_ITERNAL_Context *ctx,
/**
* Context for adding strided transitions to a DFA.
*/
-struct REGEX_ITERNAL_Strided_Context
+struct REGEX_INTERNAL_Strided_Context
{
/**
* Length of the strides.
@@ -2113,12 +2113,12 @@ struct REGEX_ITERNAL_Strided_Context
* Strided transitions DLL. New strided transitions will be stored in this DLL
* and afterwards added to the DFA.
*/
- struct REGEX_ITERNAL_Transition *transitions_head;
+ struct REGEX_INTERNAL_Transition *transitions_head;
/**
* Strided transitions DLL.
*/
- struct REGEX_ITERNAL_Transition *transitions_tail;
+ struct REGEX_INTERNAL_Transition *transitions_tail;
};
@@ -2134,16 +2134,16 @@ struct REGEX_ITERNAL_Strided_Context
*/
void
dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label,
- struct REGEX_ITERNAL_State *start,
- struct REGEX_ITERNAL_State *s)
+ struct REGEX_INTERNAL_State *start,
+ struct REGEX_INTERNAL_State *s)
{
- struct REGEX_ITERNAL_Strided_Context *ctx = cls;
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Strided_Context *ctx = cls;
+ struct REGEX_INTERNAL_Transition *t;
char *new_label;
if (depth == ctx->stride)
{
- t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition));
+ t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
t->label = GNUNET_strdup (label);
t->to_state = s;
t->from_state = start;
@@ -2184,7 +2184,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label,
*/
void
dfa_add_multi_strides (void *cls, const unsigned int count,
- struct REGEX_ITERNAL_State *s)
+ struct REGEX_INTERNAL_State *s)
{
dfa_add_multi_strides_helper (cls, 0, NULL, s, s);
}
@@ -2198,19 +2198,19 @@ dfa_add_multi_strides (void *cls, const unsigned int count,
* @param stride_len length of the strides.
*/
void
-REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx,
- struct REGEX_ITERNAL_Automaton *dfa,
+REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx,
+ struct REGEX_INTERNAL_Automaton *dfa,
const unsigned int stride_len)
{
- struct REGEX_ITERNAL_Strided_Context ctx = { stride_len, NULL, NULL };
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_Transition *t_next;
+ struct REGEX_INTERNAL_Strided_Context ctx = { stride_len, NULL, NULL };
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t_next;
if (1 > stride_len || GNUNET_YES == dfa->is_multistrided)
return;
/* Compute the new transitions of given stride_len */
- REGEX_ITERNAL_automaton_traverse (dfa, dfa->start, NULL, NULL,
+ REGEX_INTERNAL_automaton_traverse (dfa, dfa->start, NULL, NULL,
&dfa_add_multi_strides, &ctx);
/* Add all the new transitions to the automaton. */
@@ -2241,14 +2241,14 @@ REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx,
* @param transitions_tail transitions DLL.
*/
void
-dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa,
- struct REGEX_ITERNAL_State *start,
- struct REGEX_ITERNAL_State *cur, char *label,
+dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa,
+ struct REGEX_INTERNAL_State *start,
+ struct REGEX_INTERNAL_State *cur, char *label,
unsigned int max_len,
- struct REGEX_ITERNAL_Transition **transitions_head,
- struct REGEX_ITERNAL_Transition **transitions_tail)
+ struct REGEX_INTERNAL_Transition **transitions_head,
+ struct REGEX_INTERNAL_Transition **transitions_tail)
{
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t;
char *new_label;
@@ -2258,7 +2258,7 @@ dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa,
max_len == strlen (label)) ||
(start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label))))
{
- t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition));
+ t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition));
t->label = GNUNET_strdup (label);
t->to_state = cur;
t->from_state = start;
@@ -2306,15 +2306,15 @@ dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa,
* @param max_len maximal length of the compressed paths.
*/
static void
-dfa_compress_paths (struct REGEX_ITERNAL_Context *regex_ctx,
- struct REGEX_ITERNAL_Automaton *dfa, unsigned int max_len)
+dfa_compress_paths (struct REGEX_INTERNAL_Context *regex_ctx,
+ struct REGEX_INTERNAL_Automaton *dfa, unsigned int max_len)
{
- struct REGEX_ITERNAL_State *s;
- struct REGEX_ITERNAL_State *s_next;
- struct REGEX_ITERNAL_Transition *t;
- struct REGEX_ITERNAL_Transition *t_next;
- struct REGEX_ITERNAL_Transition *transitions_head = NULL;
- struct REGEX_ITERNAL_Transition *transitions_tail = NULL;
+ struct REGEX_INTERNAL_State *s;
+ struct REGEX_INTERNAL_State *s_next;
+ struct REGEX_INTERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t_next;
+ struct REGEX_INTERNAL_Transition *transitions_head = NULL;
+ struct REGEX_INTERNAL_Transition *transitions_tail = NULL;
if (NULL == dfa)
return;
@@ -2369,13 +2369,13 @@ dfa_compress_paths (struct REGEX_ITERNAL_Context *regex_ctx,
*
* @return new NFA fragment
*/
-static struct REGEX_ITERNAL_Automaton *
-nfa_fragment_create (struct REGEX_ITERNAL_State *start,
- struct REGEX_ITERNAL_State *end)
+static struct REGEX_INTERNAL_Automaton *
+nfa_fragment_create (struct REGEX_INTERNAL_State *start,
+ struct REGEX_INTERNAL_State *end)
{
- struct REGEX_ITERNAL_Automaton *n;
+ struct REGEX_INTERNAL_Automaton *n;
- n = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton));
+ n = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton));
n->type = NFA;
n->start = NULL;
@@ -2405,11 +2405,11 @@ nfa_fragment_create (struct REGEX_ITERNAL_State *start,
* @param states_tail tail of the DLL of states
*/
static void
-nfa_add_states (struct REGEX_ITERNAL_Automaton *n,
- struct REGEX_ITERNAL_State *states_head,
- struct REGEX_ITERNAL_State *states_tail)
+nfa_add_states (struct REGEX_INTERNAL_Automaton *n,
+ struct REGEX_INTERNAL_State *states_head,
+ struct REGEX_INTERNAL_State *states_tail)
{
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
if (NULL == n || NULL == states_head)
{
@@ -2443,12 +2443,12 @@ nfa_add_states (struct REGEX_ITERNAL_Automaton *n,
*
* @return new NFA state
*/
-static struct REGEX_ITERNAL_State *
-nfa_state_create (struct REGEX_ITERNAL_Context *ctx, int accepting)
+static struct REGEX_INTERNAL_State *
+nfa_state_create (struct REGEX_INTERNAL_Context *ctx, int accepting)
{
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
- s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State));
+ s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State));
s->id = ctx->state_id++;
s->accepting = accepting;
s->marked = GNUNET_NO;
@@ -2473,18 +2473,18 @@ nfa_state_create (struct REGEX_ITERNAL_Context *ctx, int accepting)
* pass NULL for epsilon transition
*/
static void
-nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret,
- struct REGEX_ITERNAL_Automaton *nfa,
- struct REGEX_ITERNAL_StateSet *states, const char *label)
+nfa_closure_set_create (struct REGEX_INTERNAL_StateSet *ret,
+ struct REGEX_INTERNAL_Automaton *nfa,
+ struct REGEX_INTERNAL_StateSet *states, const char *label)
{
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
unsigned int i;
- struct REGEX_ITERNAL_StateSet_MDLL cls_stack;
- struct REGEX_ITERNAL_State *clsstate;
- struct REGEX_ITERNAL_State *currentstate;
- struct REGEX_ITERNAL_Transition *ctran;
+ struct REGEX_INTERNAL_StateSet_MDLL cls_stack;
+ struct REGEX_INTERNAL_State *clsstate;
+ struct REGEX_INTERNAL_State *currentstate;
+ struct REGEX_INTERNAL_Transition *ctran;
- memset (ret, 0, sizeof (struct REGEX_ITERNAL_StateSet));
+ memset (ret, 0, sizeof (struct REGEX_INTERNAL_StateSet));
if (NULL == states)
return;
@@ -2528,7 +2528,7 @@ nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret,
ret->states[i]->contained = 0;
if (ret->off > 1)
- qsort (ret->states, ret->off, sizeof (struct REGEX_ITERNAL_State *),
+ qsort (ret->states, ret->off, sizeof (struct REGEX_INTERNAL_State *),
&state_compare);
}
@@ -2539,11 +2539,11 @@ nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret,
* @param ctx context
*/
static void
-nfa_add_concatenation (struct REGEX_ITERNAL_Context *ctx)
+nfa_add_concatenation (struct REGEX_INTERNAL_Context *ctx)
{
- struct REGEX_ITERNAL_Automaton *a;
- struct REGEX_ITERNAL_Automaton *b;
- struct REGEX_ITERNAL_Automaton *new_nfa;
+ struct REGEX_INTERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *b;
+ struct REGEX_INTERNAL_Automaton *new_nfa;
b = ctx->stack_tail;
GNUNET_assert (NULL != b);
@@ -2575,12 +2575,12 @@ nfa_add_concatenation (struct REGEX_ITERNAL_Context *ctx)
* @param ctx context
*/
static void
-nfa_add_star_op (struct REGEX_ITERNAL_Context *ctx)
+nfa_add_star_op (struct REGEX_INTERNAL_Context *ctx)
{
- struct REGEX_ITERNAL_Automaton *a;
- struct REGEX_ITERNAL_Automaton *new_nfa;
- struct REGEX_ITERNAL_State *start;
- struct REGEX_ITERNAL_State *end;
+ struct REGEX_INTERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *new_nfa;
+ struct REGEX_INTERNAL_State *start;
+ struct REGEX_INTERNAL_State *end;
a = ctx->stack_tail;
@@ -2618,9 +2618,9 @@ nfa_add_star_op (struct REGEX_ITERNAL_Context *ctx)
* @param ctx context
*/
static void
-nfa_add_plus_op (struct REGEX_ITERNAL_Context *ctx)
+nfa_add_plus_op (struct REGEX_INTERNAL_Context *ctx)
{
- struct REGEX_ITERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *a;
a = ctx->stack_tail;
@@ -2645,12 +2645,12 @@ nfa_add_plus_op (struct REGEX_ITERNAL_Context *ctx)
* @param ctx context
*/
static void
-nfa_add_question_op (struct REGEX_ITERNAL_Context *ctx)
+nfa_add_question_op (struct REGEX_INTERNAL_Context *ctx)
{
- struct REGEX_ITERNAL_Automaton *a;
- struct REGEX_ITERNAL_Automaton *new_nfa;
- struct REGEX_ITERNAL_State *start;
- struct REGEX_ITERNAL_State *end;
+ struct REGEX_INTERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *new_nfa;
+ struct REGEX_INTERNAL_State *start;
+ struct REGEX_INTERNAL_State *end;
a = ctx->stack_tail;
@@ -2686,13 +2686,13 @@ nfa_add_question_op (struct REGEX_ITERNAL_Context *ctx)
* @param ctx context
*/
static void
-nfa_add_alternation (struct REGEX_ITERNAL_Context *ctx)
+nfa_add_alternation (struct REGEX_INTERNAL_Context *ctx)
{
- struct REGEX_ITERNAL_Automaton *a;
- struct REGEX_ITERNAL_Automaton *b;
- struct REGEX_ITERNAL_Automaton *new_nfa;
- struct REGEX_ITERNAL_State *start;
- struct REGEX_ITERNAL_State *end;
+ struct REGEX_INTERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *b;
+ struct REGEX_INTERNAL_Automaton *new_nfa;
+ struct REGEX_INTERNAL_State *start;
+ struct REGEX_INTERNAL_State *end;
b = ctx->stack_tail;
GNUNET_assert (NULL != b);
@@ -2730,11 +2730,11 @@ nfa_add_alternation (struct REGEX_ITERNAL_Context *ctx)
* @param label label for nfa transition
*/
static void
-nfa_add_label (struct REGEX_ITERNAL_Context *ctx, const char *label)
+nfa_add_label (struct REGEX_INTERNAL_Context *ctx, const char *label)
{
- struct REGEX_ITERNAL_Automaton *n;
- struct REGEX_ITERNAL_State *start;
- struct REGEX_ITERNAL_State *end;
+ struct REGEX_INTERNAL_Automaton *n;
+ struct REGEX_INTERNAL_State *start;
+ struct REGEX_INTERNAL_State *end;
GNUNET_assert (NULL != ctx);
@@ -2753,7 +2753,7 @@ nfa_add_label (struct REGEX_ITERNAL_Context *ctx, const char *label)
* @param ctx context
*/
static void
-REGEX_ITERNAL_context_init (struct REGEX_ITERNAL_Context *ctx)
+REGEX_INTERNAL_context_init (struct REGEX_INTERNAL_Context *ctx)
{
if (NULL == ctx)
{
@@ -2773,13 +2773,13 @@ REGEX_ITERNAL_context_init (struct REGEX_ITERNAL_Context *ctx)
* @param regex regular expression string
* @param len length of the string
*
- * @return NFA, needs to be freed using REGEX_ITERNAL_destroy_automaton
+ * @return NFA, needs to be freed using REGEX_INTERNAL_destroy_automaton
*/
-struct REGEX_ITERNAL_Automaton *
-REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len)
+struct REGEX_INTERNAL_Automaton *
+REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len)
{
- struct REGEX_ITERNAL_Context ctx;
- struct REGEX_ITERNAL_Automaton *nfa;
+ struct REGEX_INTERNAL_Context ctx;
+ struct REGEX_INTERNAL_Automaton *nfa;
const char *regexp;
char curlabel[2];
char *error_msg;
@@ -2801,7 +2801,7 @@ REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len)
return NULL;
}
- REGEX_ITERNAL_context_init (&ctx);
+ REGEX_INTERNAL_context_init (&ctx);
regexp = regex;
curlabel[1] = '\0';
@@ -2924,7 +2924,7 @@ REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len)
nfa->regex = GNUNET_strdup (regex);
/* create depth-first numbering of the states for pretty printing */
- REGEX_ITERNAL_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL);
+ REGEX_INTERNAL_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL);
/* No multistriding added so far */
nfa->is_multistrided = GNUNET_NO;
@@ -2941,7 +2941,7 @@ error:
while (NULL != (nfa = ctx.stack_head))
{
GNUNET_CONTAINER_DLL_remove (ctx.stack_head, ctx.stack_tail, nfa);
- REGEX_ITERNAL_automaton_destroy (nfa);
+ REGEX_INTERNAL_automaton_destroy (nfa);
}
return NULL;
@@ -2958,17 +2958,17 @@ error:
* for starting.
*/
static void
-construct_dfa_states (struct REGEX_ITERNAL_Context *ctx,
- struct REGEX_ITERNAL_Automaton *nfa,
- struct REGEX_ITERNAL_Automaton *dfa,
- struct REGEX_ITERNAL_State *dfa_state)
-{
- struct REGEX_ITERNAL_Transition *ctran;
- struct REGEX_ITERNAL_State *new_dfa_state;
- struct REGEX_ITERNAL_State *state_contains;
- struct REGEX_ITERNAL_State *state_iter;
- struct REGEX_ITERNAL_StateSet tmp;
- struct REGEX_ITERNAL_StateSet nfa_set;
+construct_dfa_states (struct REGEX_INTERNAL_Context *ctx,
+ struct REGEX_INTERNAL_Automaton *nfa,
+ struct REGEX_INTERNAL_Automaton *dfa,
+ struct REGEX_INTERNAL_State *dfa_state)
+{
+ struct REGEX_INTERNAL_Transition *ctran;
+ struct REGEX_INTERNAL_State *new_dfa_state;
+ struct REGEX_INTERNAL_State *state_contains;
+ struct REGEX_INTERNAL_State *state_iter;
+ struct REGEX_INTERNAL_StateSet tmp;
+ struct REGEX_INTERNAL_StateSet nfa_set;
for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next)
{
@@ -3020,23 +3020,23 @@ construct_dfa_states (struct REGEX_ITERNAL_Context *ctx,
* @param max_path_len limit the path compression length to the
* given value. If set to 1, no path compression is applied. Set to 0 for
* maximal possible path compression (generally not desireable).
- * @return DFA, needs to be freed using REGEX_ITERNAL_automaton_destroy.
+ * @return DFA, needs to be freed using REGEX_INTERNAL_automaton_destroy.
*/
-struct REGEX_ITERNAL_Automaton *
-REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
+struct REGEX_INTERNAL_Automaton *
+REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len,
unsigned int max_path_len)
{
- struct REGEX_ITERNAL_Context ctx;
- struct REGEX_ITERNAL_Automaton *dfa;
- struct REGEX_ITERNAL_Automaton *nfa;
- struct REGEX_ITERNAL_StateSet nfa_start_eps_cls;
- struct REGEX_ITERNAL_StateSet singleton_set;
+ struct REGEX_INTERNAL_Context ctx;
+ struct REGEX_INTERNAL_Automaton *dfa;
+ struct REGEX_INTERNAL_Automaton *nfa;
+ struct REGEX_INTERNAL_StateSet nfa_start_eps_cls;
+ struct REGEX_INTERNAL_StateSet singleton_set;
- REGEX_ITERNAL_context_init (&ctx);
+ REGEX_INTERNAL_context_init (&ctx);
/* Create NFA */
// fprintf (stderr, "N");
- nfa = REGEX_ITERNAL_construct_nfa (regex, len);
+ nfa = REGEX_INTERNAL_construct_nfa (regex, len);
if (NULL == nfa)
{
@@ -3045,12 +3045,12 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
return NULL;
}
- dfa = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton));
+ dfa = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton));
dfa->type = DFA;
dfa->regex = GNUNET_strdup (regex);
/* Create DFA start state from epsilon closure */
- memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet));
+ memset (&singleton_set, 0, sizeof (struct REGEX_INTERNAL_StateSet));
state_set_append (&singleton_set, nfa->start);
nfa_closure_set_create (&nfa_start_eps_cls, nfa, &singleton_set, NULL);
state_set_clear (&singleton_set);
@@ -3059,20 +3059,20 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
// fprintf (stderr, "D");
construct_dfa_states (&ctx, nfa, dfa, dfa->start);
- REGEX_ITERNAL_automaton_destroy (nfa);
+ REGEX_INTERNAL_automaton_destroy (nfa);
/* Minimize DFA */
// fprintf (stderr, "M");
if (GNUNET_OK != dfa_minimize (&ctx, dfa))
{
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
return NULL;
}
/* Create proofs and hashes for all states */
if (GNUNET_OK != automaton_create_proofs (dfa))
{
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
return NULL;
}
@@ -3085,16 +3085,16 @@ REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len,
/**
- * Free the memory allocated by constructing the REGEX_ITERNAL_Automaton data
+ * Free the memory allocated by constructing the REGEX_INTERNAL_Automaton data
* structure.
*
* @param a automaton to be destroyed
*/
void
-REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a)
+REGEX_INTERNAL_automaton_destroy (struct REGEX_INTERNAL_Automaton *a)
{
- struct REGEX_ITERNAL_State *s;
- struct REGEX_ITERNAL_State *next_state;
+ struct REGEX_INTERNAL_State *s;
+ struct REGEX_INTERNAL_State *next_state;
if (NULL == a)
return;
@@ -3122,10 +3122,10 @@ REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a)
* @return 0 if string matches, non 0 otherwise
*/
static int
-evaluate_dfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
+evaluate_dfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
{
const char *strp;
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
unsigned int step_len;
if (DFA != a->type)
@@ -3165,14 +3165,14 @@ evaluate_dfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
* @return 0 if string matches, non 0 otherwise
*/
static int
-evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
+evaluate_nfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
{
const char *strp;
char str[2];
- struct REGEX_ITERNAL_State *s;
- struct REGEX_ITERNAL_StateSet sset;
- struct REGEX_ITERNAL_StateSet new_sset;
- struct REGEX_ITERNAL_StateSet singleton_set;
+ struct REGEX_INTERNAL_State *s;
+ struct REGEX_INTERNAL_StateSet sset;
+ struct REGEX_INTERNAL_StateSet new_sset;
+ struct REGEX_INTERNAL_StateSet singleton_set;
unsigned int i;
int result;
@@ -3188,7 +3188,7 @@ evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
return 0;
result = 1;
- memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet));
+ memset (&singleton_set, 0, sizeof (struct REGEX_INTERNAL_StateSet));
state_set_append (&singleton_set, a->start);
nfa_closure_set_create (&sset, a, &singleton_set, NULL);
state_set_clear (&singleton_set);
@@ -3227,7 +3227,7 @@ evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string)
* @return 0 if string matches, non 0 otherwise
*/
int
-REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, const char *string)
+REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string)
{
int result;
@@ -3262,7 +3262,7 @@ REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, const char *string)
* @return
*/
const char *
-REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a)
+REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a)
{
if (NULL == a)
return NULL;
@@ -3279,10 +3279,10 @@ REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a)
* @return number of transitions in the given automaton.
*/
unsigned int
-REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a)
+REGEX_INTERNAL_get_transition_count (struct REGEX_INTERNAL_Automaton *a)
{
unsigned int t_count;
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
if (NULL == a)
return 0;
@@ -3307,7 +3307,7 @@ REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a)
* to construct the key
*/
size_t
-REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len,
+REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len,
struct GNUNET_HashCode * key)
{
unsigned int size;
@@ -3337,7 +3337,7 @@ REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len,
* @return GNUNET_OK if the proof is valid for the given key.
*/
int
-REGEX_ITERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key)
+REGEX_INTERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key)
{
struct GNUNET_HashCode k