From 566b7539fcaf9c455da665cb641016d2cfbb1b47 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 20 Jun 2013 09:02:43 +0000 Subject: [PATCH] renaming symbols from libgnunetregextest to have the prefix REGEX_TEST --- src/regex/Makefile.am | 2 - src/regex/gnunet-daemon-regexprofiler.c | 14 +- src/regex/gnunet-regex-profiler.c | 8 +- src/regex/gnunet-regex-simulation-profiler.c | 10 +- src/regex/gnunet-service-regex.c | 14 +- src/regex/perf-regex.c | 18 +- src/regex/plugin_block_regex.c | 4 +- src/regex/regex_block_lib.c | 8 +- src/regex/regex_block_lib.h | 8 +- src/regex/regex_internal.c | 454 +++++++++---------- src/regex/regex_internal.h | 96 ++-- src/regex/regex_internal_dht.c | 66 +-- src/regex/regex_internal_lib.h | 68 +-- src/regex/regex_test_graph.c | 42 +- src/regex/regex_test_lib.c | 10 +- src/regex/regex_test_lib.h | 32 +- src/regex/regex_test_random.c | 4 +- src/regex/test_regex_eval_api.c | 42 +- src/regex/test_regex_graph_api.c | 72 +-- src/regex/test_regex_iterate_api.c | 26 +- src/regex/test_regex_proofs.c | 32 +- 21 files changed, 514 insertions(+), 516 deletions(-) diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 34ef90ca0..e1c41d91e 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am @@ -31,8 +31,6 @@ gnunet_service_regex_LDADD = -lm \ $(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 \ diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index 6a61aa6f0..3f4dd087f 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c @@ -57,7 +57,7 @@ static struct GNUNET_DHT_Handle *dht_handle; /** * Peer's regex announce handle. */ -static struct REGEX_ITERNAL_Announcement *announce_handle; +static struct REGEX_INTERNAL_Announcement *announce_handle; /** * Periodically reannounce regex. @@ -109,7 +109,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (NULL != announce_handle) { - REGEX_ITERNAL_announce_cancel (announce_handle); + REGEX_INTERNAL_announce_cancel (announce_handle); announce_handle = NULL; } @@ -160,7 +160,7 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "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, @@ -169,7 +169,7 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { GNUNET_assert (NULL != announce_handle); - REGEX_ITERNAL_reannounce (announce_handle); + REGEX_INTERNAL_reannounce (announce_handle); } random_delay = @@ -330,7 +330,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, /* 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", @@ -339,8 +339,8 @@ run (void *cls, char *const *args GNUNET_UNUSED, 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); diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index e6f35a6f4..cb257df49 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c @@ -150,7 +150,7 @@ struct RegexPeer /** * Handle to a running regex search. */ - struct REGEX_ITERNAL_Search *search_handle; + struct REGEX_INTERNAL_Search *search_handle; /** * Testbed operation handle for DHT. @@ -702,7 +702,7 @@ find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * 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. @@ -1039,7 +1039,7 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, 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); @@ -1081,7 +1081,7 @@ dht_da (void *cls, void *op_result) if (NULL != peer->search_handle) { - REGEX_ITERNAL_search_cancel (peer->search_handle); + REGEX_INTERNAL_search_cancel (peer->search_handle); peer->search_handle = NULL; } diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index b3d1ff873..dcb6c02f6 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c @@ -335,7 +335,7 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) 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; @@ -460,10 +460,10 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, 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) { @@ -473,9 +473,9 @@ announce_regex (const char *regex) 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; } diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index f0a39a361..697b04a36 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c @@ -54,12 +54,12 @@ struct ClientEntry /** * 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. @@ -143,12 +143,12 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) } 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); @@ -171,7 +171,7 @@ reannounce (void *cls, { 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); @@ -207,7 +207,7 @@ handle_announce (void *cls, } 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), @@ -311,7 +311,7 @@ handle_search (void *cls, } 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, diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c index 210b16b81..bc723b6cb 100644 --- a/src/regex/perf-regex.c +++ b/src/regex/perf-regex.c @@ -53,7 +53,7 @@ iter (void *cls, const char *proof, int accepting, unsigned int num_edges, - const struct REGEX_ITERNAL_Edge *edges) + const struct REGEX_INTERNAL_Edge *edges) { unsigned int i; @@ -66,9 +66,9 @@ iter (void *cls, } 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); } /** @@ -84,7 +84,7 @@ print_dfa (struct REGEX_ITERNAL_Automaton* dfa) int main (int argc, char *const *argv) { - struct REGEX_ITERNAL_Automaton* dfa; + struct REGEX_INTERNAL_Automaton* dfa; char **regexes; char *buffer; char *regex; @@ -98,14 +98,14 @@ main (int argc, char *const *argv) 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); @@ -114,11 +114,11 @@ main (int argc, char *const *argv) // 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; } diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 43e59ea8c..82341813e 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c @@ -107,10 +107,10 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type, 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)) { diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index 383cf5626..63b673fbe 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c @@ -92,7 +92,7 @@ check_edge (void *cls, int -REGEX_ITERNAL_block_check (const struct RegexBlock *block, +REGEX_INTERNAL_block_check (const struct RegexBlock *block, size_t size, const char *xquery) { @@ -109,7 +109,7 @@ REGEX_ITERNAL_block_check (const struct RegexBlock *block, 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; @@ -120,9 +120,9 @@ REGEX_ITERNAL_block_check (const struct RegexBlock *block, 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; diff --git a/src/regex/regex_block_lib.h b/src/regex/regex_block_lib.h index 2ef7ef30c..a6c539229 100644 --- a/src/regex/regex_block_lib.h +++ b/src/regex/regex_block_lib.h @@ -52,7 +52,7 @@ extern "C" * 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); @@ -66,7 +66,7 @@ REGEX_ITERNAL_block_check (const struct RegexBlock *block, * * @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); @@ -89,9 +89,9 @@ typedef int (*REGEX_ITERNAL_EgdeIterator)(void *cls, * 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 */ diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index e66835134..6fda695a7 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c @@ -39,17 +39,17 @@ /** * 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 key_check; @@ -3365,15 +3365,15 @@ REGEX_ITERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key) */ 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; @@ -3455,15 +3455,15 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, * @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); diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index cd76c1c73..69a8971d5 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h @@ -47,17 +47,17 @@ extern "C" * 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. @@ -72,30 +72,30 @@ struct REGEX_ITERNAL_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. @@ -112,37 +112,37 @@ struct REGEX_ITERNAL_StateSet /** * 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. @@ -222,12 +222,12 @@ struct REGEX_ITERNAL_State /** * 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. @@ -238,14 +238,14 @@ struct REGEX_ITERNAL_State * 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 @@ -255,28 +255,28 @@ enum REGEX_ITERNAL_AutomatonType /** * 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. @@ -286,17 +286,17 @@ struct REGEX_ITERNAL_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 @@ -321,10 +321,10 @@ struct REGEX_ITERNAL_Automaton * @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); /** @@ -339,9 +339,9 @@ REGEX_ITERNAL_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); /** @@ -351,9 +351,9 @@ typedef int (*REGEX_ITERNAL_traverse_check) (void *cls, * @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); /** @@ -370,11 +370,11 @@ typedef void (*REGEX_ITERNAL_traverse_action) (void *cls, * @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); /** @@ -389,7 +389,7 @@ REGEX_ITERNAL_automaton_traverse (const struct REGEX_ITERNAL_Automaton *a, * @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); /** @@ -400,14 +400,14 @@ 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); /** * 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. @@ -420,14 +420,14 @@ struct REGEX_ITERNAL_Context 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; }; @@ -439,8 +439,8 @@ struct REGEX_ITERNAL_Context * @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); diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index 0b5d99928..a11d59752 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c @@ -42,7 +42,7 @@ #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. @@ -57,7 +57,7 @@ struct REGEX_ITERNAL_Announcement /** * 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. @@ -87,9 +87,9 @@ regex_iterator (void *cls, 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; @@ -182,43 +182,43 @@ regex_iterator (void *cls, } -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); } @@ -241,7 +241,7 @@ struct RegexSearchContext /** * 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. @@ -260,7 +260,7 @@ struct RegexSearchContext * 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. @@ -300,7 +300,7 @@ struct REGEX_ITERNAL_Search /** * @param callback Callback for found peers. */ - REGEX_ITERNAL_Found callback; + REGEX_INTERNAL_Found callback; /** * @param callback_cls Closure for @c callback. @@ -352,7 +352,7 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, { 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", @@ -430,7 +430,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, { 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; @@ -466,7 +466,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, 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; @@ -543,7 +543,7 @@ regex_edge_iterator (void *cls, 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; @@ -602,7 +602,7 @@ regex_next_edge (const struct RegexBlock *block, 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; @@ -611,7 +611,7 @@ regex_next_edge (const struct RegexBlock *block, /* 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); @@ -670,14 +670,14 @@ regex_next_edge (const struct RegexBlock *block, } -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; @@ -685,10 +685,10 @@ REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht, 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; @@ -699,7 +699,7 @@ REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht, /* 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; @@ -779,7 +779,7 @@ regex_free_result (void *cls, * @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, @@ -801,7 +801,7 @@ regex_cancel_search (struct REGEX_ITERNAL_Search *ctx) } 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); diff --git a/src/regex/regex_internal_lib.h b/src/regex/regex_internal_lib.h index e138535d4..7da08154d 100644 --- a/src/regex/regex_internal_lib.h +++ b/src/regex/regex_internal_lib.h @@ -42,13 +42,13 @@ extern "C" /** * 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? @@ -77,21 +77,21 @@ struct REGEX_ITERNAL_Edge * @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); /** @@ -103,7 +103,7 @@ REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_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); @@ -119,7 +119,7 @@ REGEX_ITERNAL_eval (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); @@ -132,7 +132,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, +REGEX_INTERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key); @@ -146,12 +146,12 @@ REGEX_ITERNAL_check_proof (const char *proof, * @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); /** @@ -163,8 +163,8 @@ typedef void (*REGEX_ITERNAL_KeyIterator)(void *cls, * @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); @@ -172,16 +172,16 @@ REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a, /** * 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. @@ -190,10 +190,10 @@ struct REGEX_ITERNAL_Search; * @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, @@ -203,33 +203,33 @@ REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht, * 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, @@ -239,7 +239,7 @@ typedef void (*REGEX_ITERNAL_Found)(void *cls, /** * 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. @@ -249,23 +249,23 @@ typedef void (*REGEX_ITERNAL_Found)(void *cls, * @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 */ diff --git a/src/regex/regex_test_graph.c b/src/regex/regex_test_graph.c index 369356aa1..0684da711 100644 --- a/src/regex/regex_test_graph.c +++ b/src/regex/regex_test_graph.c @@ -29,9 +29,9 @@ /** * 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. @@ -64,12 +64,12 @@ struct REGEX_ITERNAL_Graph_Context */ 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; @@ -114,12 +114,12 @@ scc_tarjan_strongconnect (unsigned int *scc_counter, * @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) @@ -144,18 +144,18 @@ scc_tarjan (struct REGEX_ITERNAL_Automaton *a) /** * 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; @@ -268,13 +268,13 @@ REGEX_ITERNAL_automaton_save_graph_step (void *cls, unsigned int count, * 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) { @@ -290,9 +290,9 @@ REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *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) { @@ -308,8 +308,8 @@ REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a, 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"; diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index dbb864370..d39db7ef8 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c @@ -305,7 +305,7 @@ regex_ctx_destroy (struct RegexCombineCtx *ctx) * 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; @@ -333,15 +333,15 @@ REGEX_ITERNAL_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) { struct GNUNET_DISK_FileHandle *f; unsigned int nr; @@ -421,7 +421,7 @@ REGEX_ITERNAL_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) { unsigned int i; diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h index 107c2ffce..87dcadf72 100644 --- a/src/regex/regex_test_lib.h +++ b/src/regex/regex_test_lib.h @@ -25,8 +25,8 @@ * @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" @@ -46,20 +46,20 @@ extern "C" * @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); /** @@ -68,7 +68,7 @@ REGEX_ITERNAL_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); /** @@ -85,7 +85,7 @@ REGEX_ITERNAL_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); /** @@ -98,30 +98,30 @@ REGEX_ITERNAL_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 }; @@ -134,9 +134,9 @@ enum REGEX_ITERNAL_GraphSavingOptions * 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); diff --git a/src/regex/regex_test_random.c b/src/regex/regex_test_random.c index 00e4c21b3..8564da9db 100644 --- a/src/regex/regex_test_random.c +++ b/src/regex/regex_test_random.c @@ -61,7 +61,7 @@ get_random_literal () * 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; @@ -148,7 +148,7 @@ REGEX_ITERNAL_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) { unsigned int i; char *str; diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index 3ab914dc1..a3dffc022 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c @@ -67,7 +67,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, 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]; @@ -81,7 +81,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, /* 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; @@ -89,21 +89,21 @@ test_random (unsigned int rx_length, unsigned int max_str_len, { 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)) @@ -124,7 +124,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, /* 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) { @@ -132,8 +132,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, 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)) { @@ -193,7 +193,7 @@ error: * @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; @@ -213,7 +213,7 @@ test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx, 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, @@ -234,7 +234,7 @@ test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx, "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); } @@ -247,7 +247,7 @@ main (int argc, char *argv[]) { 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; @@ -337,19 +337,19 @@ main (int argc, char *argv[]) } /* 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); diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c index a0d44fb2f..cc4370c85 100644 --- a/src/regex/test_regex_graph_api.c +++ b/src/regex/test_regex_graph_api.c @@ -74,7 +74,7 @@ int 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"; @@ -98,58 +98,58 @@ main (int argc, char *argv[]) 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); } diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c index dd6c09347..cf7ee2298 100644 --- a/src/regex/test_regex_iterate_api.c +++ b/src/regex/test_regex_iterate_api.c @@ -36,7 +36,7 @@ /** * 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; @@ -61,7 +61,7 @@ struct RegexStringPair 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; @@ -101,7 +101,7 @@ key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, 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, @@ -117,7 +117,7 @@ main (int argc, char *argv[]) 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; @@ -161,7 +161,7 @@ main (int argc, char *argv[]) /* 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"); @@ -191,10 +191,10 @@ main (int argc, char *argv[]) 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) { @@ -218,7 +218,7 @@ main (int argc, char *argv[]) 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) @@ -238,9 +238,9 @@ main (int argc, char *argv[]) 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) { @@ -249,7 +249,7 @@ main (int argc, char *argv[]) error += (ctx.string_count - ctx.match_count); } - REGEX_ITERNAL_automaton_destroy (dfa); + REGEX_INTERNAL_automaton_destroy (dfa); } error += ctx.error; diff --git a/src/regex/test_regex_proofs.c b/src/regex/test_regex_proofs.c index d7c743c77..74f0c1615 100644 --- a/src/regex/test_regex_proofs.c +++ b/src/regex/test_regex_proofs.c @@ -43,17 +43,17 @@ static unsigned int 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; @@ -65,7 +65,7 @@ test_proof (const char *regex) } GNUNET_free (c_rx1); - REGEX_ITERNAL_automaton_destroy (dfa); + REGEX_INTERNAL_automaton_destroy (dfa); return error; } @@ -91,7 +91,7 @@ test_proofs_random (unsigned int count, size_t rx_length) 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); } @@ -124,20 +124,20 @@ test_proofs_static () 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; @@ -148,8 +148,8 @@ test_proofs_static () 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; -- 2.25.1