struct GNUNET_REGEX_Automaton;
/**
- * Construct an NFA data structure by parsing the regex string of
- * length len.
+ * Construct an NFA by parsing the regex string of length 'len'.
*
* @param regex regular expression string
* @param len length of the string
struct GNUNET_REGEX_Automaton *
GNUNET_REGEX_construct_nfa(const char *regex, const size_t len);
+/**
+ * Construct DFA for the given 'regex' of lenght 'len'
+ *
+ * @param regex regular expression string
+ * @param len length of the regular expression
+ *
+ * @return DFA. Needs to be freed using GNUNET_REGEX_destroy_automaton
+ */
+struct GNUNET_REGEX_Automaton *
+GNUNET_REGEX_construct_dfa (const char *regex, const size_t len);
+
/**
* Free the memory allocated by constructing the GNUNET_REGEX_Automaton
* data structure.
* @param a automaton to be destroyed
*/
void
-GNUNET_REGEX_destroy_automaton(struct GNUNET_REGEX_Automaton *a);
+GNUNET_REGEX_automaton_destroy(struct GNUNET_REGEX_Automaton *a);
/**
- * Save the given NFA as a GraphViz dot file
+ * Save the given automaton as a GraphViz dot file
*
- * @param n NFA to be saved
+ * @param a the automaton to be saved
* @param filename where to save the file
*/
void
-GNUNET_REGEX_save_nfa_graph(struct GNUNET_REGEX_Automaton *n,
- const char *filename);
-
-
-/**
- * Construct DFA for the given 'regex' of lenght 'len'
- *
- * @param regex regular expression string
- * @param len length of the regular expression
- *
- * @return DFA. Needs to be freed using GNUNET_REGEX_destroy_automaton
- */
-struct GNUNET_REGEX_Automaton *
-GNUNET_REGEX_construct_dfa (const char *regex, const size_t len);
+GNUNET_REGEX_automaton_save_graph(struct GNUNET_REGEX_Automaton *a,
+ const char *filename);
#if 0 /* keep Emacsens' auto-indent happy */
{
return l;
}
+/**
+ * Construct an NFA by parsing the regex string of length 'len'.
+ *
+ * @param regex regular expression string
+ * @param len length of the string
+ *
+ * @return NFA.Needs to be freed using GNUNET_REGEX_destroy_automaton
+ */
struct GNUNET_REGEX_Automaton *
-GNUNET_REGEX_construct_nfa (const char *regex, const size_t len)
+GNUNET_REGEX_construct_nfa(const char *regex, const size_t len)
{
struct GNUNET_REGEX_Context ctx;
struct GNUNET_REGEX_Automaton *nfa;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", error_msg);
GNUNET_free (p);
while (!stack_empty (ctx.stack))
- GNUNET_REGEX_destroy_automaton (stack_pop
- (ctx.stack,
- sizeof (struct GNUNET_REGEX_Automaton)));
+ GNUNET_REGEX_automaton_destroy (stack_pop (ctx.stack,
+ sizeof (struct GNUNET_REGEX_Automaton)));
GNUNET_REGEX_context_destroy (&ctx);
return NULL;
}
+/**
+ * Free the memory allocated by constructing the GNUNET_REGEX_Automaton
+ * data structure.
+ *
+ * @param a automaton to be destroyed
+ */
void
-GNUNET_REGEX_destroy_automaton (struct GNUNET_REGEX_Automaton *a)
+GNUNET_REGEX_automaton_destroy(struct GNUNET_REGEX_Automaton *a)
{
struct GNUNET_CONTAINER_SList_Iterator it;
GNUNET_free (a);
}
-
+/**
+ * Construct DFA for the given 'regex' of lenght 'len'
+ *
+ * @param regex regular expression string
+ * @param len length of the regular expression
+ *
+ * @return DFA. Needs to be freed using GNUNET_REGEX_destroy_automaton
+ */
struct GNUNET_REGEX_Automaton *
GNUNET_REGEX_construct_dfa (const char *regex, const size_t len)
{
GNUNET_CONTAINER_slist_iter_destroy (&tranit);
}
GNUNET_CONTAINER_slist_destroy (dfa_stack);
- GNUNET_REGEX_destroy_automaton (nfa);
+ GNUNET_REGEX_automaton_destroy (nfa);
GNUNET_REGEX_context_destroy (&ctx);
dfa_clear_nfa_set (dfa->states);
return dfa;
}
+/**
+ * Save the given automaton as a GraphViz dot file
+ *
+ * @param a the automaton to be saved
+ * @param filename where to save the file
+ */
void
-GNUNET_REGEX_save_nfa_graph (struct GNUNET_REGEX_Automaton *n,
- const char *filename)
+GNUNET_REGEX_automaton_save_graph(struct GNUNET_REGEX_Automaton *a,
+ const char *filename)
{
struct GNUNET_CONTAINER_SList_Iterator stateit;
struct GNUNET_CONTAINER_SList_Iterator tranit;
char *end;
FILE *p;
- if (NULL == n)
+ if (NULL == a)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not print NFA, was NULL!");
return;
start = "digraph G {\nrankdir=LR\n";
fwrite (start, strlen (start), 1, p);
- for (stateit = GNUNET_CONTAINER_slist_begin (n->states);
+ for (stateit = GNUNET_CONTAINER_slist_begin (a->states);
GNUNET_YES != GNUNET_CONTAINER_slist_end (&stateit);
GNUNET_CONTAINER_slist_next (&stateit))
{
if (nfa)
{
- GNUNET_REGEX_save_nfa_graph (nfa, "nfa_graph.dot");
- GNUNET_REGEX_destroy_automaton (nfa);
+ GNUNET_REGEX_automaton_save_graph (nfa, "nfa_graph.dot");
+ GNUNET_REGEX_automaton_destroy (nfa);
}
else
err = 1;
dfa = GNUNET_REGEX_construct_dfa (regex, strlen (regex));
if (dfa)
{
- GNUNET_REGEX_save_nfa_graph (dfa, "dfa_graph.dot");
- GNUNET_REGEX_destroy_automaton (dfa);
+ GNUNET_REGEX_automaton_save_graph (dfa, "dfa_graph.dot");
+ GNUNET_REGEX_automaton_destroy (dfa);
}
return err;
}