regex profiler fixes
[oweals/gnunet.git] / src / include / gnunet_regex_lib.h
index 599e92765e9b4ed91efd510f816ecfdaafa7969c..e7c525304dcd62bfb4ba6490d3238de3a3d0c646 100644 (file)
@@ -38,6 +38,12 @@ extern "C"
 #endif
 
 
+/**
+ * Constant for how many bytes the initial string regex should have.
+ */
+#define GNUNET_REGEX_INITIAL_BYTES 24
+
+
 /**
  * Maximum regex string length for use with GNUNET_REGEX_ipv4toregex
  */
@@ -73,28 +79,26 @@ struct GNUNET_REGEX_Edge
 };
 
 
-/**
- * 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);
-
-
 /**
  * Construct DFA for the given 'regex' of length 'len'.
  *
+ * Path compression means, that for example a DFA o -> a -> b -> c -> o will be
+ * compressed to o -> abc -> o. Note that this parameter influences the
+ * non-determinism of states of the resulting NFA in the DHT (number of outgoing
+ * edges with the same label). For example for an application that stores IPv4
+ * addresses as bitstrings it could make sense to limit the path compression to
+ * 4 or 8.
+ *
  * @param regex regular expression string.
  * @param len length of the regular expression.
- *
- * @return DFA, needs to be freed using GNUNET_REGEX_destroy_automaton.
+ * @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 GNUNET_REGEX_automaton_destroy.
  */
 struct GNUNET_REGEX_Automaton *
-GNUNET_REGEX_construct_dfa (const char *regex, const size_t len);
+GNUNET_REGEX_construct_dfa (const char *regex, const size_t len,
+                            int max_path_len);
 
 
 /**