$(GN_LIBINTL)
gnunet_service_regex_DEPENDENCIES = \
libgnunetregex_internal.a
-# todo: link files from libgnunetregex statically into gnunet_service_regex,
-# rename API prefix to avoid collision with 'libgnunetregexnew'...
noinst_LIBRARIES = \
libgnunetregex_internal.a \
/**
* Peer's regex announce handle.
*/
-static struct REGEX_ITERNAL_Announcement *announce_handle;
+static struct REGEX_INTERNAL_Announcement *announce_handle;
/**
* Periodically reannounce regex.
if (NULL != announce_handle)
{
- REGEX_ITERNAL_announce_cancel (announce_handle);
+ REGEX_INTERNAL_announce_cancel (announce_handle);
announce_handle = NULL;
}
"First time, creating regex: %s\n",
regex);
memset (&id, 0, sizeof (struct GNUNET_PeerIdentity));
- announce_handle = REGEX_ITERNAL_announce (dht_handle,
+ announce_handle = REGEX_INTERNAL_announce (dht_handle,
&id,
regex,
(unsigned int) max_path_compression,
else
{
GNUNET_assert (NULL != announce_handle);
- REGEX_ITERNAL_reannounce (announce_handle);
+ REGEX_INTERNAL_reannounce (announce_handle);
}
random_delay =
/* Read regexes from policy files */
GNUNET_assert (-1 != GNUNET_DISK_directory_scan (policy_dir, &scan,
(void *) (long) peer_id));
- if (NULL == (components = REGEX_ITERNAL_read_from_file (policy_filename)))
+ if (NULL == (components = REGEX_TEST_read_from_file (policy_filename)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Policy file %s contains no policies. Exiting.\n",
GNUNET_SCHEDULER_shutdown ();
return;
}
- regex = REGEX_ITERNAL_combine (components);
- REGEX_ITERNAL_free_from_file (components);
+ regex = REGEX_TEST_combine (components);
+ REGEX_TEST_free_from_file (components);
/* Announcing regexes from policy_filename */
GNUNET_asprintf (&rx_with_pfx, "%s(%s)(0|1)*", regex_prefix, regex);
/**
* Handle to a running regex search.
*/
- struct REGEX_ITERNAL_Search *search_handle;
+ struct REGEX_INTERNAL_Search *search_handle;
/**
* Testbed operation handle for DHT.
* Method called when we've found a peer that announced a regex
* that matches our search string. Now get the statistics.
*
- * @param cls Closure provided in REGEX_ITERNAL_search.
+ * @param cls Closure provided in REGEX_INTERNAL_search.
* @param id Peer providing a regex that matches the string.
* @param get_path Path of the get request.
* @param get_path_length Lenght of get_path.
GNUNET_assert (peer->dht_handle == ca_result);
peer->search_str_matched = GNUNET_NO;
- peer->search_handle = REGEX_ITERNAL_search (peer->dht_handle,
+ peer->search_handle = REGEX_INTERNAL_search (peer->dht_handle,
peer->search_str,
®ex_found_handler, peer,
NULL);
if (NULL != peer->search_handle)
{
- REGEX_ITERNAL_search_cancel (peer->search_handle);
+ REGEX_INTERNAL_search_cancel (peer->search_handle);
peer->search_handle = NULL;
}
static void
regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
int accepting, unsigned int num_edges,
- const struct REGEX_ITERNAL_Edge *edges)
+ const struct REGEX_INTERNAL_Edge *edges)
{
unsigned int i;
int result;
static int
announce_regex (const char *regex)
{
- struct REGEX_ITERNAL_Automaton *dfa;
+ struct REGEX_INTERNAL_Automaton *dfa;
dfa =
- REGEX_ITERNAL_construct_dfa (regex, strlen (regex), max_path_compression);
+ REGEX_INTERNAL_construct_dfa (regex, strlen (regex), max_path_compression);
if (NULL == dfa)
{
return GNUNET_SYSERR;
}
- REGEX_ITERNAL_iterate_all_edges (dfa, ®ex_iterator, NULL);
+ REGEX_INTERNAL_iterate_all_edges (dfa, ®ex_iterator, NULL);
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
return GNUNET_OK;
}
/**
* Search handle (if this client is searching).
*/
- struct REGEX_ITERNAL_Search *sh;
+ struct REGEX_INTERNAL_Search *sh;
/**
* Announcement handle (if this client is announcing).
*/
- struct REGEX_ITERNAL_Announcement *ah;
+ struct REGEX_INTERNAL_Announcement *ah;
/**
* Refresh frequency for announcements.
}
if (NULL != ce->ah)
{
- REGEX_ITERNAL_announce_cancel (ce->ah);
+ REGEX_INTERNAL_announce_cancel (ce->ah);
ce->ah = NULL;
}
if (NULL != ce->sh)
{
- REGEX_ITERNAL_search_cancel (ce->sh);
+ REGEX_INTERNAL_search_cancel (ce->sh);
ce->sh = NULL;
}
GNUNET_CONTAINER_DLL_remove (client_head, client_tail, ce);
{
struct ClientEntry *ce = cls;
- REGEX_ITERNAL_reannounce (ce->ah);
+ REGEX_INTERNAL_reannounce (ce->ah);
ce->refresh_task = GNUNET_SCHEDULER_add_delayed (ce->frequency,
&reannounce,
ce);
}
ce = GNUNET_new (struct ClientEntry);
ce->client = client;
- ce->ah = REGEX_ITERNAL_announce (dht,
+ ce->ah = REGEX_INTERNAL_announce (dht,
&am->pid,
regex,
ntohs (am->compression),
}
ce = GNUNET_new (struct ClientEntry);
ce->client = client;
- ce->sh = REGEX_ITERNAL_search (dht,
+ ce->sh = REGEX_INTERNAL_search (dht,
string,
&handle_search_result,
ce,
const char *proof,
int accepting,
unsigned int num_edges,
- const struct REGEX_ITERNAL_Edge *edges)
+ const struct REGEX_INTERNAL_Edge *edges)
{
unsigned int i;
}
static void
-print_dfa (struct REGEX_ITERNAL_Automaton* dfa)
+print_dfa (struct REGEX_INTERNAL_Automaton* dfa)
{
- REGEX_ITERNAL_iterate_all_edges (dfa, iter, NULL);
+ REGEX_INTERNAL_iterate_all_edges (dfa, iter, NULL);
}
/**
int
main (int argc, char *const *argv)
{
- struct REGEX_ITERNAL_Automaton* dfa;
+ struct REGEX_INTERNAL_Automaton* dfa;
char **regexes;
char *buffer;
char *regex;
usage();
return 1;
}
- regexes = REGEX_ITERNAL_read_from_file (argv[1]);
+ regexes = REGEX_TEST_read_from_file (argv[1]);
if (NULL == regexes)
{
usage();
return 2;
}
- buffer = REGEX_ITERNAL_combine (regexes);
+ buffer = REGEX_TEST_combine (regexes);
GNUNET_asprintf (®ex, "GNVPN-0001-PAD(%s)(0|1)*", buffer);
size = strlen (regex);
// return 0;
compression = atoi (argv[2]);
- dfa = REGEX_ITERNAL_construct_dfa (regex, size, compression);
+ dfa = REGEX_INTERNAL_construct_dfa (regex, size, compression);
print_dfa (dfa);
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
GNUNET_free (buffer);
- REGEX_ITERNAL_free_from_file (regexes);
+ REGEX_TEST_free_from_file (regexes);
GNUNET_free (regex);
return 0;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Block with no xquery\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " key: %s, %u edges\n",
GNUNET_h2s (&rblock->key), ntohl (rblock->n_edges));
- REGEX_ITERNAL_block_iterate (rblock, reply_block_size, &rdebug, NULL);
+ REGEX_INTERNAL_block_iterate (rblock, reply_block_size, &rdebug, NULL);
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
- switch (REGEX_ITERNAL_block_check (reply_block,
+ switch (REGEX_INTERNAL_block_check (reply_block,
reply_block_size,
xquery))
{
int
-REGEX_ITERNAL_block_check (const struct RegexBlock *block,
+REGEX_INTERNAL_block_check (const struct RegexBlock *block,
size_t size,
const char *xquery)
{
ctx.xquery = xquery;
ctx.found = GNUNET_NO;
ctx.key = GNUNET_strdup (GNUNET_h2s (&block->key));
- res = REGEX_ITERNAL_block_iterate (block, size, &check_edge, &ctx);
+ res = REGEX_INTERNAL_block_iterate (block, size, &check_edge, &ctx);
GNUNET_free (ctx.key);
if (GNUNET_SYSERR == res)
return GNUNET_SYSERR;
int
-REGEX_ITERNAL_block_iterate (const struct RegexBlock *block,
+REGEX_INTERNAL_block_iterate (const struct RegexBlock *block,
size_t size,
- REGEX_ITERNAL_EgdeIterator iterator,
+ REGEX_INTERNAL_EgdeIterator iterator,
void *iter_cls)
{
struct RegexEdge *edge;
* GNUNET_SYSERR if the block is invalid.
*/
int
-REGEX_ITERNAL_block_check (const struct RegexBlock *block,
+REGEX_INTERNAL_block_check (const struct RegexBlock *block,
size_t size,
const char *xquery);
*
* @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
*/
-typedef int (*REGEX_ITERNAL_EgdeIterator)(void *cls,
+typedef int (*REGEX_INTERNAL_EgdeIterator)(void *cls,
const char *token,
size_t len,
const struct GNUNET_HashCode *key);
* be errors in further edges.
*/
int
-REGEX_ITERNAL_block_iterate (const struct RegexBlock *block,
+REGEX_INTERNAL_block_iterate (const struct RegexBlock *block,
size_t size,
- REGEX_ITERNAL_EgdeIterator iterator,
+ REGEX_INTERNAL_EgdeIterator iterator,
void *iter_cls);
#if 0 /* keep Emacsens' auto-indent happy */
/**
* 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.
* @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);
* @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)
{
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)
* @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;
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;
}
* @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)
* @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;
* @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;
* @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;
* @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;
* @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;
* @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)
* @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++;
* @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;
* @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;
/**
- * 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.
*/
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)
* @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;
}
/* 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++)
*
* @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;
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;
}
* @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;
* @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;
}
* @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)
* @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);
* @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;
* @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;
/**
* Context for adding strided transitions to a DFA.
*/
-struct REGEX_ITERNAL_Strided_Context
+struct REGEX_INTERNAL_Strided_Context
{
/**
* Length of the strides.
* 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;
};
*/
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;
*/
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);
}
* @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. */
* @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;
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;
* @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;
*
* @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;
* @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)
{
*
* @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;
* 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;
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);
}
* @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);
* @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;
* @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;
* @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;
* @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);
* @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);
* @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)
{
* @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;
return NULL;
}
- REGEX_ITERNAL_context_init (&ctx);
+ REGEX_INTERNAL_context_init (&ctx);
regexp = regex;
curlabel[1] = '\0';
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;
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;
* 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)
{
* @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)
{
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);
// 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;
}
/**
- * 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;
* @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)
* @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;
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);
* @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;
* @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;
* @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;
* 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;
* @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 key_check;
*/
static void
iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
- char *consumed_string, struct REGEX_ITERNAL_State *state,
- REGEX_ITERNAL_KeyIterator iterator, void *iterator_cls)
+ char *consumed_string, struct REGEX_INTERNAL_State *state,
+ REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
{
unsigned int i;
char *temp;
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_Transition *t;
unsigned int num_edges = state->transition_count;
- struct REGEX_ITERNAL_Edge edges[num_edges];
- struct REGEX_ITERNAL_Edge edge[1];
+ struct REGEX_INTERNAL_Edge edges[num_edges];
+ struct REGEX_INTERNAL_Edge edge[1];
struct GNUNET_HashCode hash;
struct GNUNET_HashCode hash_new;
* @param iterator_cls closure.
*/
void
-REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a,
- REGEX_ITERNAL_KeyIterator iterator,
+REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a,
+ REGEX_INTERNAL_KeyIterator iterator,
void *iterator_cls)
{
- struct REGEX_ITERNAL_State *s;
+ struct REGEX_INTERNAL_State *s;
for (s = a->states_head; NULL != s; s = s->next)
{
- struct REGEX_ITERNAL_Edge edges[s->transition_count];
+ struct REGEX_INTERNAL_Edge edges[s->transition_count];
unsigned int num_edges;
num_edges = state_get_edges (s, edges);
* which they origin ('from_state'). Each state can have 0-n transitions.
* If label is NULL, this is considered to be an epsilon transition.
*/
-struct REGEX_ITERNAL_Transition
+struct REGEX_INTERNAL_Transition
{
/**
* This is a linked list.
*/
- struct REGEX_ITERNAL_Transition *prev;
+ struct REGEX_INTERNAL_Transition *prev;
/**
* This is a linked list.
*/
- struct REGEX_ITERNAL_Transition *next;
+ struct REGEX_INTERNAL_Transition *next;
/**
* Unique id of this transition.
/**
* State to which this transition leads.
*/
- struct REGEX_ITERNAL_State *to_state;
+ struct REGEX_INTERNAL_State *to_state;
/**
* State from which this transition origins.
*/
- struct REGEX_ITERNAL_State *from_state;
+ struct REGEX_INTERNAL_State *from_state;
};
/**
* A state. Can be used in DFA and NFA automatons.
*/
-struct REGEX_ITERNAL_State;
+struct REGEX_INTERNAL_State;
/**
* Set of states.
*/
-struct REGEX_ITERNAL_StateSet
+struct REGEX_INTERNAL_StateSet
{
/**
* Array of states.
*/
- struct REGEX_ITERNAL_State **states;
+ struct REGEX_INTERNAL_State **states;
/**
* Number of entries in *use* in the 'states' array.
/**
* A state. Can be used in DFA and NFA automatons.
*/
-struct REGEX_ITERNAL_State
+struct REGEX_INTERNAL_State
{
/**
* This is a linked list to keep states in an automaton.
*/
- struct REGEX_ITERNAL_State *prev;
+ struct REGEX_INTERNAL_State *prev;
/**
* This is a linked list to keep states in an automaton.
*/
- struct REGEX_ITERNAL_State *next;
+ struct REGEX_INTERNAL_State *next;
/**
* This is a multi DLL for StateSet_MDLL.
*/
- struct REGEX_ITERNAL_State *prev_SS;
+ struct REGEX_INTERNAL_State *prev_SS;
/**
* This is a multi DLL for StateSet_MDLL.
*/
- struct REGEX_ITERNAL_State *next_SS;
+ struct REGEX_INTERNAL_State *next_SS;
/**
* This is a multi DLL for StateSet_MDLL Stack.
*/
- struct REGEX_ITERNAL_State *prev_ST;
+ struct REGEX_INTERNAL_State *prev_ST;
/**
* This is a multi DLL for StateSet_MDLL Stack.
*/
- struct REGEX_ITERNAL_State *next_ST;
+ struct REGEX_INTERNAL_State *next_ST;
/**
* Unique state id.
/**
* DLL of transitions.
*/
- struct REGEX_ITERNAL_Transition *transitions_head;
+ struct REGEX_INTERNAL_Transition *transitions_head;
/**
* DLL of transitions.
*/
- struct REGEX_ITERNAL_Transition *transitions_tail;
+ struct REGEX_INTERNAL_Transition *transitions_tail;
/**
* Number of incoming transitions. Used for compressing DFA paths.
* Set of states on which this state is based on. Used when creating a DFA out
* of several NFA states.
*/
- struct REGEX_ITERNAL_StateSet nfa_set;
+ struct REGEX_INTERNAL_StateSet nfa_set;
};
/**
* Type of an automaton.
*/
-enum REGEX_ITERNAL_AutomatonType
+enum REGEX_INTERNAL_AutomatonType
{
NFA,
DFA
/**
* Automaton representation.
*/
-struct REGEX_ITERNAL_Automaton
+struct REGEX_INTERNAL_Automaton
{
/**
* Linked list of NFAs used for partial NFA creation.
*/
- struct REGEX_ITERNAL_Automaton *prev;
+ struct REGEX_INTERNAL_Automaton *prev;
/**
* Linked list of NFAs used for partial NFA creation.
*/
- struct REGEX_ITERNAL_Automaton *next;
+ struct REGEX_INTERNAL_Automaton *next;
/**
* First state of the automaton. This is mainly used for constructing an NFA,
* where each NFA itself consists of one or more NFAs linked together.
*/
- struct REGEX_ITERNAL_State *start;
+ struct REGEX_INTERNAL_State *start;
/**
* End state of the partial NFA. This is undefined for DFAs
*/
- struct REGEX_ITERNAL_State *end;
+ struct REGEX_INTERNAL_State *end;
/**
* Number of states in the automaton.
/**
* DLL of states.
*/
- struct REGEX_ITERNAL_State *states_head;
+ struct REGEX_INTERNAL_State *states_head;
/**
* DLL of states
*/
- struct REGEX_ITERNAL_State *states_tail;
+ struct REGEX_INTERNAL_State *states_tail;
/**
* Type of the automaton.
*/
- enum REGEX_ITERNAL_AutomatonType type;
+ enum REGEX_INTERNAL_AutomatonType type;
/**
* Regex
* @param regex regular expression string.
* @param len length of the string.
*
- * @return NFA, needs to be freed using REGEX_ITERNAL_automaton_destroy.
+ * @return NFA, needs to be freed using REGEX_INTERNAL_automaton_destroy.
*/
-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);
/**
*
* @return GNUNET_YES to proceed traversal, GNUNET_NO to stop.
*/
-typedef int (*REGEX_ITERNAL_traverse_check) (void *cls,
- struct REGEX_ITERNAL_State * s,
- struct REGEX_ITERNAL_Transition * t);
+typedef int (*REGEX_INTERNAL_traverse_check) (void *cls,
+ struct REGEX_INTERNAL_State * s,
+ struct REGEX_INTERNAL_Transition * t);
/**
* @param count current count of the state, from 0 to a->state_count -1.
* @param s state.
*/
-typedef void (*REGEX_ITERNAL_traverse_action) (void *cls,
+typedef void (*REGEX_INTERNAL_traverse_action) (void *cls,
const unsigned int count,
- struct REGEX_ITERNAL_State * s);
+ struct REGEX_INTERNAL_State * s);
/**
* @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);
/**
* @return canonical regex string.
*/
const char *
-REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a);
+REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_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);
/**
* Context that contains an id counter for states and transitions as well as a
* DLL of automatons used as a stack for NFA construction.
*/
-struct REGEX_ITERNAL_Context
+struct REGEX_INTERNAL_Context
{
/**
* Unique state id.
unsigned int transition_id;
/**
- * DLL of REGEX_ITERNAL_Automaton's used as a stack.
+ * DLL of REGEX_INTERNAL_Automaton's used as a stack.
*/
- struct REGEX_ITERNAL_Automaton *stack_head;
+ struct REGEX_INTERNAL_Automaton *stack_head;
/**
- * DLL of REGEX_ITERNAL_Automaton's used as a stack.
+ * DLL of REGEX_INTERNAL_Automaton's used as a stack.
*/
- struct REGEX_ITERNAL_Automaton *stack_tail;
+ struct REGEX_INTERNAL_Automaton *stack_tail;
};
* @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);
#define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
#endif
-struct REGEX_ITERNAL_Announcement
+struct REGEX_INTERNAL_Announcement
{
/**
* DHT handle to use, must be initialized externally.
/**
* Automaton representation of the regex (expensive to build).
*/
- struct REGEX_ITERNAL_Automaton* dfa;
+ struct REGEX_INTERNAL_Automaton* dfa;
/**
* Identity under which to announce the regex.
const char *proof,
int accepting,
unsigned int num_edges,
- const struct REGEX_ITERNAL_Edge *edges)
+ const struct REGEX_INTERNAL_Edge *edges)
{
- struct REGEX_ITERNAL_Announcement *h = cls;
+ struct REGEX_INTERNAL_Announcement *h = cls;
struct RegexBlock *block;
struct RegexEdge *block_edge;
size_t size;
}
-struct REGEX_ITERNAL_Announcement *
-REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht,
+struct REGEX_INTERNAL_Announcement *
+REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht,
const struct GNUNET_PeerIdentity *id,
const char *regex,
uint16_t compression,
struct GNUNET_STATISTICS_Handle *stats)
{
- struct REGEX_ITERNAL_Announcement *h;
+ struct REGEX_INTERNAL_Announcement *h;
GNUNET_assert (NULL != dht);
- h = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Announcement));
+ h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Announcement));
h->regex = regex;
h->dht = dht;
h->stats = stats;
h->id = *id;
- h->dfa = REGEX_ITERNAL_construct_dfa (regex,
+ h->dfa = REGEX_INTERNAL_construct_dfa (regex,
strlen (regex),
compression);
- REGEX_ITERNAL_reannounce (h);
+ REGEX_INTERNAL_reannounce (h);
return h;
}
void
-REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h)
+REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h)
{
GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */
- LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_ITERNAL_reannounce: %.60s\n", h->regex);
+ LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_reannounce: %.60s\n", h->regex);
LOG (GNUNET_ERROR_TYPE_DEBUG, " full: %s\n", h->regex);
- REGEX_ITERNAL_iterate_all_edges (h->dfa, ®ex_iterator, h);
+ REGEX_INTERNAL_iterate_all_edges (h->dfa, ®ex_iterator, h);
}
void
-REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h)
+REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h)
{
- REGEX_ITERNAL_automaton_destroy (h->dfa);
+ REGEX_INTERNAL_automaton_destroy (h->dfa);
GNUNET_free (h);
}
/**
* Information about the search.
*/
- struct REGEX_ITERNAL_Search *info;
+ struct REGEX_INTERNAL_Search *info;
/**
* We just want to look for one edge, the longer the better.
* Struct to keep information of searches of services described by a regex
* using a user-provided string service description.
*/
-struct REGEX_ITERNAL_Search
+struct REGEX_INTERNAL_Search
{
/**
* DHT handle to use, must be initialized externally.
/**
* @param callback Callback for found peers.
*/
- REGEX_ITERNAL_Found callback;
+ REGEX_INTERNAL_Found callback;
/**
* @param callback_cls Closure for @c callback.
{
const struct RegexAccept *block = data;
struct RegexSearchContext *ctx = cls;
- struct REGEX_ITERNAL_Search *info = ctx->info;
+ struct REGEX_INTERNAL_Search *info = ctx->info;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Got regex results from DHT!\n");
LOG (GNUNET_ERROR_TYPE_INFO, " accept for %s (key %s)\n",
{
const struct RegexBlock *block = data;
struct RegexSearchContext *ctx = cls;
- struct REGEX_ITERNAL_Search *info = ctx->info;
+ struct REGEX_INTERNAL_Search *info = ctx->info;
void *copy;
size_t len;
char *datastore;
memcpy (proof, &block[1], len);
proof[len] = '\0';
- if (GNUNET_OK != REGEX_ITERNAL_check_proof (proof, key))
+ if (GNUNET_OK != REGEX_INTERNAL_check_proof (proof, key))
{
GNUNET_break_op (0);
return;
const struct GNUNET_HashCode *key)
{
struct RegexSearchContext *ctx = cls;
- struct REGEX_ITERNAL_Search *info = ctx->info;
+ struct REGEX_INTERNAL_Search *info = ctx->info;
const char *current;
size_t current_len;
struct RegexSearchContext *ctx)
{
struct RegexSearchContext *new_ctx;
- struct REGEX_ITERNAL_Search *info = ctx->info;
+ struct REGEX_INTERNAL_Search *info = ctx->info;
struct GNUNET_DHT_GetHandle *get_h;
struct GNUNET_HashCode *hash;
const char *rest;
/* Find the longest match for the current string position,
* among tokens in the given block */
ctx->longest_match = 0;
- result = REGEX_ITERNAL_block_iterate (block, size,
+ result = REGEX_INTERNAL_block_iterate (block, size,
®ex_edge_iterator, ctx);
GNUNET_break (GNUNET_OK == result);
}
-struct REGEX_ITERNAL_Search *
-REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht,
+struct REGEX_INTERNAL_Search *
+REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
const char *string,
- REGEX_ITERNAL_Found callback,
+ REGEX_INTERNAL_Found callback,
void *callback_cls,
struct GNUNET_STATISTICS_Handle *stats)
{
- struct REGEX_ITERNAL_Search *h;
+ struct REGEX_INTERNAL_Search *h;
struct GNUNET_DHT_GetHandle *get_h;
struct RegexSearchContext *ctx;
struct GNUNET_HashCode key;
size_t len;
/* Initialize handle */
- LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_ITERNAL_search: %s\n", string);
+ LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_search: %s\n", string);
GNUNET_assert (NULL != dht);
GNUNET_assert (NULL != callback);
- h = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Search));
+ h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Search));
h->dht = dht;
h->description = GNUNET_strdup (string);
h->callback = callback;
/* Initialize context */
len = strlen (string);
- size = REGEX_ITERNAL_get_first_key (string, len, &key);
+ size = REGEX_INTERNAL_get_first_key (string, len, &key);
ctx = GNUNET_malloc (sizeof (struct RegexSearchContext));
ctx->position = size;
ctx->info = h;
* @param ctx The search context.
*/
static void
-regex_cancel_search (struct REGEX_ITERNAL_Search *ctx)
+regex_cancel_search (struct REGEX_INTERNAL_Search *ctx)
{
GNUNET_free (ctx->description);
GNUNET_CONTAINER_multihashmap_iterate (ctx->dht_get_handles,
}
void
-REGEX_ITERNAL_search_cancel (struct REGEX_ITERNAL_Search *h)
+REGEX_INTERNAL_search_cancel (struct REGEX_INTERNAL_Search *h)
{
regex_cancel_search (h);
GNUNET_free (h);
/**
* Automaton (NFA/DFA) representation.
*/
-struct REGEX_ITERNAL_Automaton;
+struct REGEX_INTERNAL_Automaton;
/**
* Edge representation.
*/
-struct REGEX_ITERNAL_Edge
+struct REGEX_INTERNAL_Edge
{
/**
* Label of the edge. FIXME: might want to not consume exactly multiples of 8 bits, need length?
* @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);
/**
- * Free the memory allocated by constructing the REGEX_ITERNAL_Automaton.
+ * 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);
/**
* @return 0 if string matches, non 0 otherwise.
*/
int
-REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a,
+REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a,
const char *string);
* 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);
* @return GNUNET_OK if the proof is valid for the given key.
*/
int
-REGEX_ITERNAL_check_proof (const char *proof,
+REGEX_INTERNAL_check_proof (const char *proof,
const struct GNUNET_HashCode *key);
* @param num_edges number of edges leaving current state.
* @param edges edges leaving current state.
*/
-typedef void (*REGEX_ITERNAL_KeyIterator)(void *cls,
+typedef void (*REGEX_INTERNAL_KeyIterator)(void *cls,
const struct GNUNET_HashCode *key,
const char *proof,
int accepting,
unsigned int num_edges,
- const struct REGEX_ITERNAL_Edge *edges);
+ const struct REGEX_INTERNAL_Edge *edges);
/**
* @param iterator_cls closure.
*/
void
-REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a,
- REGEX_ITERNAL_KeyIterator iterator,
+REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a,
+ REGEX_INTERNAL_KeyIterator iterator,
void *iterator_cls);
/**
* Handle to store cached data about a regex announce.
*/
-struct REGEX_ITERNAL_Announcement;
+struct REGEX_INTERNAL_Announcement;
/**
* Handle to store data about a regex search.
*/
-struct REGEX_ITERNAL_Search;
+struct REGEX_INTERNAL_Search;
/**
* Announce a regular expression: put all states of the automaton in the DHT.
- * Does not free resources, must call REGEX_ITERNAL_announce_cancel for that.
+ * Does not free resources, must call REGEX_INTERNAL_announce_cancel for that.
*
* @param dht An existing and valid DHT service handle. CANNOT be NULL.
* @param id ID to announce as provider of regex. Own ID in most cases.
* @param stats Optional statistics handle to report usage. Can be NULL.
*
* @return Handle to reuse o free cached resources.
- * Must be freed by calling REGEX_ITERNAL_announce_cancel.
+ * Must be freed by calling REGEX_INTERNAL_announce_cancel.
*/
-struct REGEX_ITERNAL_Announcement *
-REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht,
+struct REGEX_INTERNAL_Announcement *
+REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht,
const struct GNUNET_PeerIdentity *id,
const char *regex,
uint16_t compression,
* Announce again a regular expression previously announced.
* Does use caching to speed up process.
*
- * @param h Handle returned by a previous REGEX_ITERNAL_announce call.
+ * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
*/
void
-REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h);
+REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h);
/**
* Clear all cached data used by a regex announce.
* Does not close DHT connection.
*
- * @param h Handle returned by a previous REGEX_ITERNAL_announce call.
+ * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
*/
void
-REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h);
+REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h);
/**
* Search callback function.
*
- * @param cls Closure provided in REGEX_ITERNAL_search.
+ * @param cls Closure provided in REGEX_INTERNAL_search.
* @param id Peer providing a regex that matches the string.
* @param get_path Path of the get request.
* @param get_path_length Lenght of get_path.
* @param put_path Path of the put request.
* @param put_path_length Length of the put_path.
*/
-typedef void (*REGEX_ITERNAL_Found)(void *cls,
+typedef void (*REGEX_INTERNAL_Found)(void *cls,
const struct GNUNET_PeerIdentity *id,
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
/**
* Search for a peer offering a regex matching certain string in the DHT.
- * The search runs until REGEX_ITERNAL_search_cancel is called, even if results
+ * The search runs until REGEX_INTERNAL_search_cancel is called, even if results
* are returned.
*
* @param dht An existing and valid DHT service handle.
* @param stats Optional statistics handle to report usage. Can be NULL.
*
* @return Handle to stop search and free resources.
- * Must be freed by calling REGEX_ITERNAL_search_cancel.
+ * Must be freed by calling REGEX_INTERNAL_search_cancel.
*/
-struct REGEX_ITERNAL_Search *
-REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht,
+struct REGEX_INTERNAL_Search *
+REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
const char *string,
- REGEX_ITERNAL_Found callback,
+ REGEX_INTERNAL_Found callback,
void *callback_cls,
struct GNUNET_STATISTICS_Handle *stats);
/**
- * Stop search and free all data used by a REGEX_ITERNAL_search call.
+ * Stop search and free all data used by a REGEX_INTERNAL_search call.
* Does not close DHT connection.
*
- * @param h Handle returned by a previous REGEX_ITERNAL_search call.
+ * @param h Handle returned by a previous REGEX_INTERNAL_search call.
*/
void
-REGEX_ITERNAL_search_cancel (struct REGEX_ITERNAL_Search *h);
+REGEX_INTERNAL_search_cancel (struct REGEX_INTERNAL_Search *h);
#if 0 /* keep Emacsens' auto-indent happy */
/**
* Context for graph creation. Passed as the cls to
- * REGEX_ITERNAL_automaton_save_graph_step.
+ * REGEX_TEST_automaton_save_graph_step.
*/
-struct REGEX_ITERNAL_Graph_Context
+struct REGEX_TEST_Graph_Context
{
/**
* File pointer to the dot file used for output.
*/
static void
scc_tarjan_strongconnect (unsigned int *scc_counter,
- struct REGEX_ITERNAL_State *v, unsigned int *index,
- struct REGEX_ITERNAL_State **stack,
+ struct REGEX_INTERNAL_State *v, unsigned int *index,
+ struct REGEX_INTERNAL_State **stack,
unsigned int *stack_size)
{
- struct REGEX_ITERNAL_State *w;
- struct REGEX_ITERNAL_Transition *t;
+ struct REGEX_INTERNAL_State *w;
+ struct REGEX_INTERNAL_Transition *t;
v->index = *index;
v->lowlink = *index;
* @param a the automaton for which SCCs should be computed and assigned.
*/
static void
-scc_tarjan (struct REGEX_ITERNAL_Automaton *a)
+scc_tarjan (struct REGEX_INTERNAL_Automaton *a)
{
unsigned int index;
unsigned int scc_counter;
- struct REGEX_ITERNAL_State *v;
- struct REGEX_ITERNAL_State *stack[a->state_count];
+ struct REGEX_INTERNAL_State *v;
+ struct REGEX_INTERNAL_State *stack[a->state_count];
unsigned int stack_size;
for (v = a->states_head; NULL != v; v = v->next)
/**
* Save a state to an open file pointer. cls is expected to be a file pointer to
* an open file. Used only in conjunction with
- * REGEX_ITERNAL_automaton_save_graph.
+ * REGEX_TEST_automaton_save_graph.
*
* @param cls file pointer.
* @param count current count of the state, not used.
* @param s state.
*/
void
-REGEX_ITERNAL_automaton_save_graph_step (void *cls, unsigned int count,
- struct REGEX_ITERNAL_State *s)
+REGEX_TEST_automaton_save_graph_step (void *cls, unsigned int count,
+ struct REGEX_INTERNAL_State *s)
{
- struct REGEX_ITERNAL_Graph_Context *ctx = cls;
- struct REGEX_ITERNAL_Transition *ctran;
+ struct REGEX_TEST_Graph_Context *ctx = cls;
+ struct REGEX_INTERNAL_Transition *ctran;
char *s_acc = NULL;
char *s_tran = NULL;
char *name;
* mode
*/
void
-REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a,
+REGEX_TEST_automaton_save_graph (struct REGEX_INTERNAL_Automaton *a,
const char *filename,
- enum REGEX_ITERNAL_GraphSavingOptions options)
+ enum REGEX_TEST_GraphSavingOptions options)
{
char *start;
char *end;
- struct REGEX_ITERNAL_Graph_Context ctx;
+ struct REGEX_TEST_Graph_Context ctx;
if (NULL == a)
{
ctx.filep = fopen (filename, "w");
ctx.verbose =
- (0 == (options & REGEX_ITERNAL_GRAPH_VERBOSE)) ? GNUNET_NO : GNUNET_YES;
+ (0 == (options & REGEX_TEST_GRAPH_VERBOSE)) ? GNUNET_NO : GNUNET_YES;
ctx.coloring =
- (0 == (options & REGEX_ITERNAL_GRAPH_COLORING)) ? GNUNET_NO : GNUNET_YES;
+ (0 == (options & REGEX_TEST_GRAPH_COLORING)) ? GNUNET_NO : GNUNET_YES;
if (NULL == ctx.filep)
{
start = "digraph G {\nrankdir=LR\n";
fwrite (start, strlen (start), 1, ctx.filep);
- REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL,
- ®EX_ITERNAL_automaton_save_graph_step,
+ REGEX_INTERNAL_automaton_traverse (a, a->start, NULL, NULL,
+ ®EX_TEST_automaton_save_graph_step,
&ctx);
end = "\n}\n";
* This function DOES NOT support arbitrary regex combining.
*/
char *
-REGEX_ITERNAL_combine (char * const regexes[])
+REGEX_TEST_combine (char * const regexes[])
{
unsigned int i;
char *combined;
/**
* Read a set of regexes from a file, one per line and return them in an array
- * suitable for REGEX_ITERNAL_combine.
- * The array must be free'd using REGEX_ITERNAL_free_from_file.
+ * suitable for REGEX_TEST_combine.
+ * The array must be free'd using REGEX_TEST_free_from_file.
*
* @param filename Name of the file containing the regexes.
*
* @return A newly allocated, NULL terminated array of regexes.
*/
char **
-REGEX_ITERNAL_read_from_file (const char *filename)
+REGEX_TEST_read_from_file (const char *filename)
{
struct GNUNET_DISK_FileHandle *f;
unsigned int nr;
* @param regexes NULL-terminated array of regexes.
*/
void
-REGEX_ITERNAL_free_from_file (char **regexes)
+REGEX_TEST_free_from_file (char **regexes)
{
unsigned int i;
* @author Bertlomiej Polot
*/
-#ifndef REGEX_ITERNAL_TEST_LIB_H
-#define REGEX_ITERNAL_TEST_LIB_H
+#ifndef REGEX_INTERNAL_TEST_LIB_H
+#define REGEX_INTERNAL_TEST_LIB_H
#include "regex_internal_lib.h"
* @return A string with a single regex that matches any of the original regexes
*/
char *
-REGEX_ITERNAL_combine(char * const regexes[]);
+REGEX_TEST_combine(char * const regexes[]);
/**
* Read a set of regexes from a file, one per line and return them in an array
- * suitable for REGEX_ITERNAL_combine.
- * The array must be free'd using REGEX_ITERNAL_free_from_file.
+ * suitable for REGEX_TEST_combine.
+ * The array must be free'd using REGEX_TEST_free_from_file.
*
* @param filename Name of the file containing the regexes.
*
* @return A newly allocated, NULL terminated array of regexes.
*/
char **
-REGEX_ITERNAL_read_from_file (const char *filename);
+REGEX_TEST_read_from_file (const char *filename);
/**
* @param regexes NULL-terminated array of regexes.
*/
void
-REGEX_ITERNAL_free_from_file (char **regexes);
+REGEX_TEST_free_from_file (char **regexes);
/**
* needs to be freed, otherwise.
*/
char *
-REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str);
+REGEX_TEST_generate_random_regex (size_t rx_length, char *matching_str);
/**
* @return random string that needs to be freed.
*/
char *
-REGEX_ITERNAL_generate_random_string (size_t max_len);
+REGEX_TEST_generate_random_string (size_t max_len);
/**
* Options for graph creation function
- * REGEX_ITERNAL_automaton_save_graph.
+ * REGEX_TEST_automaton_save_graph.
*/
-enum REGEX_ITERNAL_GraphSavingOptions
+enum REGEX_TEST_GraphSavingOptions
{
/**
* Default. Do nothing special.
*/
- REGEX_ITERNAL_GRAPH_DEFAULT = 0,
+ REGEX_TEST_GRAPH_DEFAULT = 0,
/**
* The generated graph will include extra information such as the NFA states
* that were used to generate the DFA state.
*/
- REGEX_ITERNAL_GRAPH_VERBOSE = 1,
+ REGEX_TEST_GRAPH_VERBOSE = 1,
/**
* Enable graph coloring. Will color each SCC in a different color.
*/
- REGEX_ITERNAL_GRAPH_COLORING = 2
+ REGEX_TEST_GRAPH_COLORING = 2
};
* mode
*/
void
-REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a,
+REGEX_TEST_automaton_save_graph (struct REGEX_INTERNAL_Automaton *a,
const char *filename,
- enum REGEX_ITERNAL_GraphSavingOptions options);
+ enum REGEX_TEST_GraphSavingOptions options);
* needs to be freed, otherwise.
*/
char *
-REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str)
+REGEX_TEST_generate_random_regex (size_t rx_length, char *matching_str)
{
char *rx;
char *rx_p;
* @return random string that needs to be freed.
*/
char *
-REGEX_ITERNAL_generate_random_string (size_t max_len)
+REGEX_TEST_generate_random_string (size_t max_len)
{
unsigned int i;
char *str;
int eval_check;
int eval_canonical;
int eval_canonical_check;
- struct REGEX_ITERNAL_Automaton *dfa;
+ struct REGEX_INTERNAL_Automaton *dfa;
regex_t rx;
regmatch_t matchptr[1];
char error[200];
/* Generate random regex and a string that matches the regex */
matching_str = GNUNET_malloc (rx_length + 1);
- rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, matching_str);
+ rand_rx = REGEX_TEST_generate_random_regex (rx_length, matching_str);
/* Now match */
result = 0;
{
if (0 < i)
{
- matching_str = REGEX_ITERNAL_generate_random_string (max_str_len);
+ matching_str = REGEX_TEST_generate_random_string (max_str_len);
}
/* Match string using DFA */
- dfa = REGEX_ITERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0);
+ dfa = REGEX_INTERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0);
if (NULL == dfa)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n");
goto error;
}
- eval = REGEX_ITERNAL_eval (dfa, matching_str);
+ eval = REGEX_INTERNAL_eval (dfa, matching_str);
/* save the canonical regex for later comparison */
- canonical_regex = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa));
- REGEX_ITERNAL_automaton_destroy (dfa);
+ canonical_regex = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (dfa));
+ REGEX_INTERNAL_automaton_destroy (dfa);
/* Match string using glibc regex */
if (0 != regcomp (&rx, rand_rx, REG_EXTENDED))
/* Match canonical regex */
dfa =
- REGEX_ITERNAL_construct_dfa (canonical_regex, strlen (canonical_regex),
+ REGEX_INTERNAL_construct_dfa (canonical_regex, strlen (canonical_regex),
0);
if (NULL == dfa)
{
goto error;
}
- eval_canonical = REGEX_ITERNAL_eval (dfa, matching_str);
- REGEX_ITERNAL_automaton_destroy (dfa);
+ eval_canonical = REGEX_INTERNAL_eval (dfa, matching_str);
+ REGEX_INTERNAL_automaton_destroy (dfa);
if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED))
{
* @return 0 on successfull, non 0 otherwise
*/
int
-test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx,
+test_automaton (struct REGEX_INTERNAL_Automaton *a, regex_t * rx,
struct Regex_String_Pair *rxstr)
{
int result;
for (i = 0; i < rxstr->string_count; i++)
{
- eval = REGEX_ITERNAL_eval (a, rxstr->strings[i]);
+ eval = REGEX_INTERNAL_eval (a, rxstr->strings[i]);
eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0);
/* We only want to match the whole string, because that's what our DFA does,
"string: %s\nexpected result: %i\n"
"gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n"
"rm_so: %i\nrm_eo: %i\n\n", rxstr->regex,
- REGEX_ITERNAL_get_canonical_regex (a), rxstr->strings[i],
+ REGEX_INTERNAL_get_canonical_regex (a), rxstr->strings[i],
rxstr->expected_results[i], eval, eval_check, error,
matchptr[0].rm_so, matchptr[0].rm_eo);
}
{
GNUNET_log_setup ("test-regex", "WARNING", NULL);
- struct REGEX_ITERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *a;
regex_t rx;
int i;
int check_nfa;
}
/* NFA test */
- a = REGEX_ITERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex));
+ a = REGEX_INTERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex));
check_nfa += test_automaton (a, &rx, &rxstr[i]);
- REGEX_ITERNAL_automaton_destroy (a);
+ REGEX_INTERNAL_automaton_destroy (a);
/* DFA test */
- a = REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
+ a = REGEX_INTERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
check_dfa += test_automaton (a, &rx, &rxstr[i]);
- check_proof = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (a));
- REGEX_ITERNAL_automaton_destroy (a);
+ check_proof = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (a));
+ REGEX_INTERNAL_automaton_destroy (a);
- a = REGEX_ITERNAL_construct_dfa (check_proof, strlen (check_proof), 0);
+ a = REGEX_INTERNAL_construct_dfa (check_proof, strlen (check_proof), 0);
check_dfa += test_automaton (a, &rx, &rxstr[i]);
- REGEX_ITERNAL_automaton_destroy (a);
+ REGEX_INTERNAL_automaton_destroy (a);
if (0 != check_dfa)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof);
GNUNET_free_non_null (check_proof);
main (int argc, char *argv[])
{
int error;
- struct REGEX_ITERNAL_Automaton *a;
+ struct REGEX_INTERNAL_Automaton *a;
unsigned int i;
const char *filename = "test_graph.dot";
for (i = 0; i < 12; i++)
{
/* Check NFA graph creation */
- a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i]));
- REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i]));
+ REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i]));
- REGEX_ITERNAL_automaton_save_graph (a, filename,
- REGEX_ITERNAL_GRAPH_DEFAULT |
- REGEX_ITERNAL_GRAPH_VERBOSE);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i]));
+ REGEX_TEST_automaton_save_graph (a, filename,
+ REGEX_TEST_GRAPH_DEFAULT |
+ REGEX_TEST_GRAPH_VERBOSE);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i]));
- REGEX_ITERNAL_automaton_save_graph (a, filename,
- REGEX_ITERNAL_GRAPH_DEFAULT |
- REGEX_ITERNAL_GRAPH_COLORING);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i]));
+ REGEX_TEST_automaton_save_graph (a, filename,
+ REGEX_TEST_GRAPH_DEFAULT |
+ REGEX_TEST_GRAPH_COLORING);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i]));
- REGEX_ITERNAL_automaton_save_graph (a, filename,
- REGEX_ITERNAL_GRAPH_DEFAULT |
- REGEX_ITERNAL_GRAPH_VERBOSE |
- REGEX_ITERNAL_GRAPH_COLORING);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i]));
+ REGEX_TEST_automaton_save_graph (a, filename,
+ REGEX_TEST_GRAPH_DEFAULT |
+ REGEX_TEST_GRAPH_VERBOSE |
+ REGEX_TEST_GRAPH_COLORING);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
/* Check DFA graph creation */
- a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
- REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
+ REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
- REGEX_ITERNAL_automaton_save_graph (a, filename,
- REGEX_ITERNAL_GRAPH_DEFAULT |
- REGEX_ITERNAL_GRAPH_VERBOSE);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
+ REGEX_TEST_automaton_save_graph (a, filename,
+ REGEX_TEST_GRAPH_DEFAULT |
+ REGEX_TEST_GRAPH_VERBOSE);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
- REGEX_ITERNAL_automaton_save_graph (a, filename,
- REGEX_ITERNAL_GRAPH_DEFAULT |
- REGEX_ITERNAL_GRAPH_COLORING);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0);
+ REGEX_TEST_automaton_save_graph (a, filename,
+ REGEX_TEST_GRAPH_DEFAULT |
+ REGEX_TEST_GRAPH_COLORING);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
- a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 4);
- REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT);
- REGEX_ITERNAL_automaton_destroy (a);
+ a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 4);
+ REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT);
+ REGEX_INTERNAL_automaton_destroy (a);
error += filecheck (filename);
}
/**
* Set to GNUNET_YES to save a debug graph.
*/
-#define REGEX_ITERNAL_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO
+#define REGEX_INTERNAL_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO
static unsigned int transition_counter;
static void
key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
int accepting, unsigned int num_edges,
- const struct REGEX_ITERNAL_Edge *edges)
+ const struct REGEX_INTERNAL_Edge *edges)
{
unsigned int i;
struct IteratorContext *ctx = cls;
ctx->match_count++;
}
- if (GNUNET_OK != REGEX_ITERNAL_check_proof (proof, key))
+ if (GNUNET_OK != REGEX_INTERNAL_check_proof (proof, key))
{
ctx->error++;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_log_setup ("test-regex", "WARNING", NULL);
int error;
- struct REGEX_ITERNAL_Automaton *dfa;
+ struct REGEX_INTERNAL_Automaton *dfa;
unsigned int i;
unsigned int num_transitions;
char *filename = NULL;
/* Create graph */
- if (GNUNET_YES == REGEX_ITERNAL_ITERATE_SAVE_DEBUG_GRAPH)
+ if (GNUNET_YES == REGEX_INTERNAL_ITERATE_SAVE_DEBUG_GRAPH)
{
GNUNET_asprintf (&filename, "iteration_graph_%u.dot", i);
ctx.graph_filep = fopen (filename, "w");
ctx.strings = rxstr[i].strings;
ctx.match_count = 0;
dfa =
- REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
- REGEX_ITERNAL_iterate_all_edges (dfa, key_iterator, &ctx);
+ REGEX_INTERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
+ REGEX_INTERNAL_iterate_all_edges (dfa, key_iterator, &ctx);
num_transitions =
- REGEX_ITERNAL_get_transition_count (dfa) - dfa->start->transition_count;
+ REGEX_INTERNAL_get_transition_count (dfa) - dfa->start->transition_count;
if (transition_counter < num_transitions)
{
error += (ctx.string_count - ctx.match_count);
}
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
/* Finish graph */
if (GNUNET_YES == ctx.should_save_graph)
ctx.match_count = 0;
dfa =
- REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
- REGEX_ITERNAL_dfa_add_multi_strides (NULL, dfa, 2);
- REGEX_ITERNAL_iterate_all_edges (dfa, key_iterator, &ctx);
+ REGEX_INTERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
+ REGEX_INTERNAL_dfa_add_multi_strides (NULL, dfa, 2);
+ REGEX_INTERNAL_iterate_all_edges (dfa, key_iterator, &ctx);
if (ctx.match_count < ctx.string_count)
{
error += (ctx.string_count - ctx.match_count);
}
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
}
error += ctx.error;
test_proof (const char *regex)
{
unsigned int error;
- struct REGEX_ITERNAL_Automaton *dfa;
+ struct REGEX_INTERNAL_Automaton *dfa;
char *c_rx1;
const char *c_rx2;
- dfa = REGEX_ITERNAL_construct_dfa (regex, strlen (regex), 1);
+ dfa = REGEX_INTERNAL_construct_dfa (regex, strlen (regex), 1);
GNUNET_assert (NULL != dfa);
- c_rx1 = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa));
- REGEX_ITERNAL_automaton_destroy (dfa);
- dfa = REGEX_ITERNAL_construct_dfa (c_rx1, strlen (c_rx1), 1);
+ c_rx1 = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (dfa));
+ REGEX_INTERNAL_automaton_destroy (dfa);
+ dfa = REGEX_INTERNAL_construct_dfa (c_rx1, strlen (c_rx1), 1);
GNUNET_assert (NULL != dfa);
- c_rx2 = REGEX_ITERNAL_get_canonical_regex (dfa);
+ c_rx2 = REGEX_INTERNAL_get_canonical_regex (dfa);
error = (0 == strcmp (c_rx1, c_rx2)) ? 0 : 1;
}
GNUNET_free (c_rx1);
- REGEX_ITERNAL_automaton_destroy (dfa);
+ REGEX_INTERNAL_automaton_destroy (dfa);
return error;
}
for (i = 0; i < count; i++)
{
- rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, NULL);
+ rand_rx = REGEX_TEST_generate_random_regex (rx_length, NULL);
failures += test_proof (rand_rx);
GNUNET_free (rand_rx);
}
const char *canon_rx1;
const char *canon_rx2;
- struct REGEX_ITERNAL_Automaton *dfa1;
- struct REGEX_ITERNAL_Automaton *dfa2;
+ struct REGEX_INTERNAL_Automaton *dfa1;
+ struct REGEX_INTERNAL_Automaton *dfa2;
error = 0;
for (i = 0; i < 8; i += 2)
{
- dfa1 = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 1);
- dfa2 = REGEX_ITERNAL_construct_dfa (regex[i + 1], strlen (regex[i + 1]), 1);
+ dfa1 = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 1);
+ dfa2 = REGEX_INTERNAL_construct_dfa (regex[i + 1], strlen (regex[i + 1]), 1);
GNUNET_assert (NULL != dfa1);
GNUNET_assert (NULL != dfa2);
- canon_rx1 = REGEX_ITERNAL_get_canonical_regex (dfa1);
- canon_rx2 = REGEX_ITERNAL_get_canonical_regex (dfa2);
+ canon_rx1 = REGEX_INTERNAL_get_canonical_regex (dfa1);
+ canon_rx2 = REGEX_INTERNAL_get_canonical_regex (dfa2);
error += (0 == strcmp (canon_rx1, canon_rx2)) ? 0 : 1;
regex[i], canon_rx1, regex[i + 1], canon_rx2);
}
- REGEX_ITERNAL_automaton_destroy (dfa1);
- REGEX_ITERNAL_automaton_destroy (dfa2);
+ REGEX_INTERNAL_automaton_destroy (dfa1);
+ REGEX_INTERNAL_automaton_destroy (dfa2);
}
return error;