gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20800 - in gnunet/src: include regex


From: gnunet
Subject: [GNUnet-SVN] r20800 - in gnunet/src: include regex
Date: Wed, 28 Mar 2012 17:49:20 +0200

Author: szengel
Date: 2012-03-28 17:49:20 +0200 (Wed, 28 Mar 2012)
New Revision: 20800

Modified:
   gnunet/src/include/gnunet_regex_lib.h
   gnunet/src/regex/regex.c
   gnunet/src/regex/test_regex.c
Log:
api changes


Modified: gnunet/src/include/gnunet_regex_lib.h
===================================================================
--- gnunet/src/include/gnunet_regex_lib.h       2012-03-28 14:20:59 UTC (rev 
20799)
+++ gnunet/src/include/gnunet_regex_lib.h       2012-03-28 15:49:20 UTC (rev 
20800)
@@ -43,8 +43,7 @@
 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
@@ -55,36 +54,35 @@
 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);
+GNUNET_REGEX_automaton_save_graph(struct GNUNET_REGEX_Automaton *a,
+                                  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);
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/regex/regex.c
===================================================================
--- gnunet/src/regex/regex.c    2012-03-28 14:20:59 UTC (rev 20799)
+++ gnunet/src/regex/regex.c    2012-03-28 15:49:20 UTC (rev 20800)
@@ -724,8 +724,16 @@
   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;
@@ -862,15 +870,20 @@
     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;
 
@@ -888,7 +901,14 @@
   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)
 {
@@ -966,7 +986,7 @@
     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);
 
@@ -976,9 +996,15 @@
   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;
@@ -990,7 +1016,7 @@
   char *end;
   FILE *p;
 
-  if (NULL == n)
+  if (NULL == a)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not print NFA, was NULL!");
     return;
@@ -1014,7 +1040,7 @@
   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))
   {

Modified: gnunet/src/regex/test_regex.c
===================================================================
--- gnunet/src/regex/test_regex.c       2012-03-28 14:20:59 UTC (rev 20799)
+++ gnunet/src/regex/test_regex.c       2012-03-28 15:49:20 UTC (rev 20800)
@@ -53,8 +53,8 @@
 
   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;
@@ -62,8 +62,8 @@
   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;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]