*/
struct GNUNET_REGEX_Automaton;
+
/**
- * State representation.
+ * Edge representation.
*/
-struct GNUNET_REGEX_State;
+struct GNUNET_REGEX_Edge
+{
+ /**
+ * Label of the edge. FIXME: might want to not consume exactly multiples of 8 bits, need length?
+ */
+ const char *label;
+
+ /**
+ * Destionation of the edge.
+ */
+ struct GNUNET_HashCode destination;
+};
+
/**
* Construct an NFA by parsing the regex string of length 'len'.
struct GNUNET_REGEX_Automaton *
GNUNET_REGEX_construct_nfa (const char *regex, const size_t len);
+
/**
* Construct DFA for the given 'regex' of length 'len'.
*
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.
void
GNUNET_REGEX_automaton_destroy (struct GNUNET_REGEX_Automaton *a);
+
/**
* Save the given automaton as a GraphViz dot file.
*
const char *string);
-
/**
- * Get the starting state of the given automaton 'a'.
+ * Get the first key for the given 'input_string'. This hashes
+ * the first x bits of the 'input_string'.
*
- * @param a automaton.
+ * @param input_string string.
+ * @param string_len length of the 'input_string'.
+ * @param key pointer to where to write the hash code.
*
- * @return starting state.
- */
-struct GNUNET_REGEX_State *
-GNUNET_REGEX_automaton_get_start (struct GNUNET_REGEX_Automaton *a);
-
-
-/**
* @return number of bits of 'input_string' that have been consumed
* to construct the key
*/
-unsigned int
-GNUNET_REGEX_get_first_key (const char *input_string,
- GNUNET_HashCode *key);
-
+size_t
+GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len,
+ struct GNUNET_HashCode * key);
/**
- * @return GNUNET_OK if the proof is valid for the given key
+ * Check if the given 'proof' matches the given 'key'.
+ *
+ * @param proof partial regex of a state.
+ * @param key hash of a state.
+ *
+ * @return GNUNET_OK if the proof is valid for the given key.
*/
int
GNUNET_REGEX_check_proof (const char *proof,
- const GNUNET_HashCode *key);
-
-
-struct GNUNET_REGEX_Edge
-{
- const char *label;
- GNUNET_HashCode destination;
-};
-
-
-typedef void (*GNUNET_REGEX_KeyIterator)(void *cls,
- const GNUNET_HashCode *key,
- const char *proof,
- unsigned int num_edges,
- const struct GNUNET_REGEX_Edge *edges);
-
-
-int
-GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a,
- GNUNET_REGEX_KeyIterator iterator,
- void *iterator_cls);
+ const struct GNUNET_HashCode *key);
/**
- * Get the next states, starting from states 's'.
- *
- * @param a automaton.
- * @param s states.
- * @param count number of states given in 's'. Will contain number of
- * states that were returned upon return.
+ * Iterator callback function.
*
- * @return next states, 'count' will contain the number of states.
+ * @param cls closure.
+ * @param key hash for current state.
+ * @param proof proof for current state.
+ * @param accepting GNUNET_YES if this is an accepting state, GNUNET_NO if not.
+ * @param num_edges number of edges leaving current state.
+ * @param edges edges leaving current state.
*/
-struct GNUNET_REGEX_State **
-GNUNET_REGEX_automaton_states_get_next (struct GNUNET_REGEX_Automaton *a,
- struct GNUNET_REGEX_State **s,
- unsigned int *count);
+typedef void (*GNUNET_REGEX_KeyIterator)(void *cls,
+ const struct GNUNET_HashCode *key,
+ const char *proof,
+ int accepting,
+ unsigned int num_edges,
+ const struct GNUNET_REGEX_Edge *edges);
+
/**
- * Hash a set of states.
+ * Iterate over all edges starting from start state of automaton 'a'. Calling
+ * iterator for each edge.
*
* @param a automaton.
- * @param s states.
- * @param count number of states.
- *
- * @return hash.
+ * @param iterator iterator called for each edge.
+ * @param iterator_cls closure.
*/
-struct GNUNET_HashCode
-GNUNET_REGEX_automaton_states_hash (struct GNUNET_REGEX_Automaton *a,
- struct GNUNET_REGEX_State **s,
- unsigned int count);
-
-
+void
+GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a,
+ GNUNET_REGEX_KeyIterator iterator,
+ void *iterator_cls);
#if 0 /* keep Emacsens' auto-indent happy */