gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35788 - gnunet/src/regex


From: gnunet
Subject: [GNUnet-SVN] r35788 - gnunet/src/regex
Date: Fri, 22 May 2015 15:26:37 +0200

Author: grothoff
Date: 2015-05-22 15:26:36 +0200 (Fri, 22 May 2015)
New Revision: 35788

Modified:
   gnunet/src/regex/regex_block_lib.h
   gnunet/src/regex/regex_internal.c
   gnunet/src/regex/regex_internal_dht.c
   gnunet/src/regex/regex_internal_lib.h
   gnunet/src/regex/test_regex_integration.c
Log:
add logging and in particular checks to make sure no '.' wildcards are during 
initial transitions of the DFA

Modified: gnunet/src/regex/regex_block_lib.h
===================================================================
--- gnunet/src/regex/regex_block_lib.h  2015-05-22 12:42:58 UTC (rev 35787)
+++ gnunet/src/regex/regex_block_lib.h  2015-05-22 13:26:36 UTC (rev 35788)
@@ -52,7 +52,8 @@
 struct REGEX_BLOCK_Edge
 {
   /**
-   * Label of the edge.  FIXME: might want to not consume exactly multiples of 
8 bits, need length!
+   * Label of the edge.  FIXME: might want to not consume exactly
+   * multiples of 8 bits, need length!
    */
   const char *label;
 
@@ -67,10 +68,9 @@
  * Check if the given 'proof' matches the given 'key'.
  *
  * @param proof partial regex of a state
- * @param proof_len number of bytes in 'proof'
+ * @param proof_len number of bytes in @a proof
  * @param key hash of a state.
- *
- * @return GNUNET_OK if the proof is valid for the given key.
+ * @return #GNUNET_OK if the proof is valid for the given key.
  */
 int
 REGEX_BLOCK_check_proof (const char *proof,
@@ -82,14 +82,13 @@
  * Check if the regex block is well formed, including all edges.
  *
  * @param block The start of the block.
- * @param size The size of the block.
- * @param query the query for the block
+ * @param size The size of the @a block.
+ * @param query the query for the @a block
  * @param xquery String describing the edge we are looking for.
  *               Can be NULL in case this is a put block.
- *
- * @return GNUNET_OK in case it's fine.
- *         GNUNET_NO in case the xquery exists and is not found (IRRELEVANT).
- *         GNUNET_SYSERR if the block is invalid.
+ * @return #GNUNET_OK in case it's fine.
+ *         #GNUNET_NO in case the xquery exists and is not found (IRRELEVANT).
+ *         #GNUNET_SYSERR if the block is invalid.
  */
 int
 REGEX_BLOCK_check (const struct RegexBlock *block,
@@ -107,13 +106,13 @@
  * @param token Token that follows to next state.
  * @param len Length of token.
  * @param key Hash of next state.
- *
- * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
+ * @return #GNUNET_YES if should keep iterating, #GNUNET_NO otherwise.
  */
-typedef int (*REGEX_INTERNAL_EgdeIterator)(void *cls,
-                                          const char *token,
-                                          size_t len,
-                                          const struct GNUNET_HashCode *key);
+typedef int
+(*REGEX_INTERNAL_EgdeIterator)(void *cls,
+                               const char *token,
+                               size_t len,
+                               const struct GNUNET_HashCode *key);
 
 
 /**
@@ -122,29 +121,29 @@
  * @param block Block to iterate over.
  * @param size Size of block.
  * @param iterator Function to call on each edge in the block.
- * @param iter_cls Closure for the iterator.
- *
- * @return GNUNET_SYSERR if an error has been encountered.
- *         GNUNET_OK if no error has been encountered.
+ * @param iter_cls Closure for the @a iterator.
+ * @return #GNUNET_SYSERR if an error has been encountered.
+ *         #GNUNET_OK if no error has been encountered.
  *           Note that if the iterator stops the iteration by returning
- *         GNUNET_NO, the block will no longer be checked for further errors.
- *           The return value will be GNUNET_OK meaning that no errors were
+ *         #GNUNET_NO, the block will no longer be checked for further errors.
+ *           The return value will be #GNUNET_OK meaning that no errors were
  *         found until the edge last notified to the iterator, but there might
  *         be errors in further edges.
  */
 int
 REGEX_BLOCK_iterate (const struct RegexBlock *block,
-                            size_t size,
-                            REGEX_INTERNAL_EgdeIterator iterator,
-                            void *iter_cls);
+                     size_t size,
+                     REGEX_INTERNAL_EgdeIterator iterator,
+                     void *iter_cls);
 
+
 /**
  * Obtain the key that a particular block is to be stored under.
  *
  * @param block block to get the key from
- * @param block_len number of bytes in block
+ * @param block_len number of bytes in @a block
  * @param key where to store the key
- * @return GNUNET_OK on success, GNUNET_SYSERR if the block is malformed
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block is malformed
  */
 int
 REGEX_BLOCK_get_key (const struct RegexBlock *block,
@@ -157,7 +156,7 @@
  *
  * @param block block to test
  * @param size number of bytes in block
- * @return GNUNET_YES if the block is accepting, GNUNET_NO if not
+ * @return #GNUNET_YES if the block is accepting, #GNUNET_NO if not
  */
 int
 GNUNET_BLOCK_is_accepting (const struct RegexBlock *block,

Modified: gnunet/src/regex/regex_internal.c
===================================================================
--- gnunet/src/regex/regex_internal.c   2015-05-22 12:42:58 UTC (rev 35787)
+++ gnunet/src/regex/regex_internal.c   2015-05-22 13:26:36 UTC (rev 35788)
@@ -31,7 +31,7 @@
 
 
 /**
- * Set this to GNUNET_YES to enable state naming. Used to debug NFA->DFA
+ * Set this to #GNUNET_YES to enable state naming. Used to debug NFA->DFA
  * creation. Disabled by default for better performance.
  */
 #define REGEX_DEBUG_DFA GNUNET_NO
@@ -59,7 +59,7 @@
 
 
 /**
- * Append state to the given StateSet '
+ * Append state to the given StateSet.
  *
  * @param set set to be modified
  * @param state state to be appended
@@ -95,7 +95,7 @@
 
 
 /**
- * Adds a transition from one state to another on 'label'. Does not add
+ * Adds a transition from one state to another on @a label. Does not add
  * duplicate states.
  *
  * @param ctx context
@@ -105,7 +105,8 @@
  */
 static void
 state_add_transition (struct REGEX_INTERNAL_Context *ctx,
-                      struct REGEX_INTERNAL_State *from_state, const char 
*label,
+                      struct REGEX_INTERNAL_State *from_state,
+                      const char *label,
                       struct REGEX_INTERNAL_State *to_state)
 {
   struct REGEX_INTERNAL_Transition *t;
@@ -113,7 +114,8 @@
 
   if (NULL == from_state)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not create Transition.\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Could not create Transition.\n");
     return;
   }
 
@@ -196,16 +198,17 @@
 
 
 /**
- * Get all edges leaving state 's'.
+ * Get all edges leaving state @a s.
  *
  * @param s state.
- * @param edges all edges leaving 's', expected to be allocated and have enough
- *        space for s->transitions_count elements.
+ * @param edges all edges leaving @a s, expected to be allocated and have 
enough
+ *        space for `s->transitions_count` elements.
  *
  * @return number of edges.
  */
 static unsigned int
-state_get_edges (struct REGEX_INTERNAL_State *s, struct REGEX_BLOCK_Edge 
*edges)
+state_get_edges (struct REGEX_INTERNAL_State *s,
+                 struct REGEX_BLOCK_Edge *edges)
 {
   struct REGEX_INTERNAL_Transition *t;
   unsigned int count;
@@ -293,7 +296,7 @@
 
 
 /**
- * Frees the memory used by State 's'
+ * Frees the memory used by State @a s
  *
  * @param s state that should be destroyed
  */
@@ -498,17 +501,17 @@
  * @param start start state, pass a->start or NULL to traverse the whole 
automaton.
  * @param check function that is checked before advancing on each transition
  *              in the DFS.
- * @param check_cls closure for check.
+ * @param check_cls closure for @a check.
  * @param action action to be performed on each state.
- * @param action_cls closure for action
+ * @param action_cls closure for @a action
  */
 void
 REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a,
-                                 struct REGEX_INTERNAL_State *start,
-                                 REGEX_INTERNAL_traverse_check check,
-                                 void *check_cls,
-                                 REGEX_INTERNAL_traverse_action action,
-                                 void *action_cls)
+                                   struct REGEX_INTERNAL_State *start,
+                                   REGEX_INTERNAL_traverse_check check,
+                                   void *check_cls,
+                                   REGEX_INTERNAL_traverse_action action,
+                                   void *action_cls)
 {
   unsigned int count;
   struct REGEX_INTERNAL_State *s;
@@ -532,8 +535,9 @@
   else
     s = start;
 
-  automaton_state_traverse (s, marks, &count, check, check_cls, action,
-                            action_cls);
+  automaton_state_traverse (s, marks, &count,
+                            check, check_cls,
+                            action, action_cls);
 }
 
 
@@ -559,7 +563,7 @@
   size_t slen;
 
   /**
-   * Number of bytes allocated for 'sbuf'
+   * Number of bytes allocated for @e sbuf
    */
   unsigned int blen;
 
@@ -570,7 +574,7 @@
 
   /**
    * If this entry is part of the last/current generation array,
-   * this flag is GNUNET_YES if the last and current generation are
+   * this flag is #GNUNET_YES if the last and current generation are
    * identical (and thus copying is unnecessary if the value didn't
    * change).  This is used in an optimization that improves
    * performance by about 1% --- if we use int16_t here.  With just
@@ -604,8 +608,8 @@
     return -1;
   return memcmp (s1->sbuf, s2->sbuf, s1->slen);
 }
-       
 
+
 /**
  * Compare two strings for equality.
  *
@@ -622,8 +626,8 @@
     return -1;
   return memcmp (s1->sbuf, s2->sbuf, s1->slen);
 }
-       
 
+
 /**
  * Reallocate the buffer of 'ret' to fit 'nlen' characters;
  * move the existing string to the beginning of the new buffer.
@@ -669,8 +673,8 @@
          sarg->slen);
   ret->slen += sarg->slen;
 }
-       
 
+
 /**
  * Append a C string.
  *
@@ -693,8 +697,8 @@
          cstr_len);
   ret->slen += cstr_len;
 }
-       
 
+
 /**
  * Wrap a string buffer, that is, set ret to the format string
  * which contains an "%s" which is to be replaced with the original
@@ -854,7 +858,7 @@
 static void
 sb_strdup (struct StringBuffer *out,
           const struct StringBuffer *in)
-       
+
 {
   out->null_flag = in->null_flag;
   if (GNUNET_YES == out->null_flag)
@@ -900,12 +904,12 @@
 
 
 /**
- * Check if the given string 'str' needs parentheses around it when
+ * Check if the given string @a str needs parentheses around it when
  * using it to generate a regex.
  *
  * @param str string
  *
- * @return GNUNET_YES if parentheses are needed, GNUNET_NO otherwise
+ * @return #GNUNET_YES if parentheses are needed, #GNUNET_NO otherwise
  */
 static int
 needs_parentheses (const struct StringBuffer *str)
@@ -949,9 +953,9 @@
 
 
 /**
- * Remove parentheses surrounding string 'str'.
+ * Remove parentheses surrounding string @a str.
  * Example: "(a)" becomes "a", "(a|b)|(a|c)" stays the same.
- * You need to GNUNET_free the returned string.
+ * You need to #GNUNET_free() the returned string.
  *
  * @param str string, modified to contain a
  * @return string without surrounding parentheses, string 'str' if no preceding
@@ -1799,8 +1803,10 @@
   for (i = 0; i < nfa_states->off; i++)
   {
     cstate = nfa_states->states[i];
-    GNUNET_snprintf (pos, pos - s->name + len,
-                    "%i,", cstate->id);
+    GNUNET_snprintf (pos,
+                     pos - s->name + len,
+                    "%i,",
+                     cstate->id);
     pos += strlen (pos);
 
     /* Add a transition for each distinct label to NULL state */
@@ -1867,16 +1873,18 @@
 
 
 /**
- * Set the given state 'marked' to GNUNET_YES. Used by the
- * 'dfa_remove_unreachable_states' function to detect unreachable states in the
+ * Set the given state 'marked' to #GNUNET_YES. Used by the
+ * #dfa_remove_unreachable_states() function to detect unreachable states in 
the
  * automaton.
  *
  * @param cls closure, not used.
  * @param count count, not used.
- * @param s state where the marked attribute will be set to GNUNET_YES.
+ * @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_INTERNAL_State 
*s)
+mark_states (void *cls,
+             const unsigned int count,
+             struct REGEX_INTERNAL_State *s)
 {
   s->marked = GNUNET_YES;
 }
@@ -1958,7 +1966,7 @@
  *
  * @param ctx context
  * @param a DFA automaton
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
  */
 static int
 dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx,
@@ -3115,10 +3123,11 @@
  * @param a automaton, type must be DFA
  * @param string string that should be evaluated
  *
- * @return 0 if string matches, non 0 otherwise
+ * @return 0 if string matches, non-0 otherwise
  */
 static int
-evaluate_dfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
+evaluate_dfa (struct REGEX_INTERNAL_Automaton *a,
+              const char *string)
 {
   const char *strp;
   struct REGEX_INTERNAL_State *s;
@@ -3157,11 +3166,11 @@
  *
  * @param a automaton, type must be NFA
  * @param string string that should be evaluated
- *
- * @return 0 if string matches, non 0 otherwise
+ * @return 0 if string matches, non-0 otherwise
  */
 static int
-evaluate_nfa (struct REGEX_INTERNAL_Automaton *a, const char *string)
+evaluate_nfa (struct REGEX_INTERNAL_Automaton *a,
+              const char *string)
 {
   const char *strp;
   char str[2];
@@ -3215,15 +3224,15 @@
 
 
 /**
- * Evaluates the given 'string' against the given compiled regex
+ * Evaluates the given @a string against the given compiled regex @a a
  *
  * @param a automaton
  * @param string string to check
- *
- * @return 0 if string matches, non 0 otherwise
+ * @return 0 if string matches, non-0 otherwise
  */
 int
-REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string)
+REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a,
+                     const char *string)
 {
   int result;
 
@@ -3292,19 +3301,19 @@
 
 
 /**
- * Get the first key for the given 'input_string'. This hashes the first x bits
- * of the 'input_string'.
+ * Get the first key for the given @a input_string. This hashes the first x 
bits
+ * of the @a input_string.
  *
  * @param input_string string.
- * @param string_len length of the 'input_string'.
+ * @param string_len length of the @a input_string.
  * @param key pointer to where to write the hash code.
- *
- * @return number of bits of 'input_string' that have been consumed
+ * @return number of bits of @a input_string that have been consumed
  *         to construct the key
  */
 size_t
-REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len,
-                            struct GNUNET_HashCode * key)
+REGEX_INTERNAL_get_first_key (const char *input_string,
+                              size_t string_len,
+                              struct GNUNET_HashCode *key)
 {
   size_t size;
 
@@ -3330,12 +3339,15 @@
  * @param consumed_string string consumed by traversing the graph till this 
state.
  * @param state current state of the automaton.
  * @param iterator iterator function called for each edge.
- * @param iterator_cls closure for the iterator function.
+ * @param iterator_cls closure for the @a iterator function.
  */
 static void
-iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
-                      char *consumed_string, struct REGEX_INTERNAL_State 
*state,
-                      REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
+iterate_initial_edge (unsigned int min_len,
+                      unsigned int max_len,
+                      char *consumed_string,
+                      struct REGEX_INTERNAL_State *state,
+                      REGEX_INTERNAL_KeyIterator iterator,
+                      void *iterator_cls)
 {
   char *temp;
   struct REGEX_INTERNAL_Transition *t;
@@ -3351,21 +3363,36 @@
   else
     cur_len = 0;
 
-  if ((cur_len >= min_len || GNUNET_YES == state->accepting) && cur_len > 0 &&
-      NULL != consumed_string)
+  if ( ( (cur_len >= min_len) ||
+         (GNUNET_YES == state->accepting) ) &&
+       (cur_len > 0) &&
+       (NULL != consumed_string) )
   {
     if (cur_len <= max_len)
     {
-      if (state->proof != NULL && 0 != strcmp (consumed_string, state->proof))
+      if ( (NULL != state->proof) &&
+           (0 != strcmp (consumed_string,
+                         state->proof)) )
       {
         (void) state_get_edges (state, edges);
-        GNUNET_CRYPTO_hash (consumed_string, strlen (consumed_string), &hash);
-        iterator (iterator_cls, &hash, consumed_string, state->accepting,
+        GNUNET_CRYPTO_hash (consumed_string,
+                            strlen (consumed_string),
+                            &hash);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Start state for string `%s' is %s\n",
+                    consumed_string,
+                    GNUNET_h2s (&hash));
+        iterator (iterator_cls,
+                  &hash,
+                  consumed_string,
+                  state->accepting,
                   num_edges, edges);
       }
 
-      if (GNUNET_YES == state->accepting && cur_len > 1 &&
-          state->transition_count < 1 && cur_len < max_len)
+      if ( (GNUNET_YES == state->accepting) &&
+           (cur_len > 1) &&
+           (state->transition_count < 1) &&
+           (cur_len < max_len) )
       {
         /* Special case for regex consisting of just a string that is shorter 
than
          * max_len */
@@ -3373,8 +3400,18 @@
         edge[0].destination = state->hash;
         temp = GNUNET_strdup (consumed_string);
         temp[cur_len - 1] = '\0';
-        GNUNET_CRYPTO_hash (temp, cur_len - 1, &hash_new);
-        iterator (iterator_cls, &hash_new, temp, GNUNET_NO, 1, edge);
+        GNUNET_CRYPTO_hash (temp,
+                            cur_len - 1,
+                            &hash_new);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Start state for short string `%s' is %s\n",
+                    temp,
+                    GNUNET_h2s (&hash_new));
+        iterator (iterator_cls,
+                  &hash_new,
+                  temp,
+                  GNUNET_NO, 1,
+                  edge);
         GNUNET_free (temp);
       }
     }
@@ -3386,7 +3423,17 @@
       temp = GNUNET_strdup (consumed_string);
       temp[max_len] = '\0';
       GNUNET_CRYPTO_hash (temp, max_len, &hash);
-      iterator (iterator_cls, &hash, temp, GNUNET_NO, 1, edge);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Start state at split edge `%s'-`%s` is %s\n",
+                  temp,
+                  edge[0].label,
+                  GNUNET_h2s (&hash_new));
+      iterator (iterator_cls,
+                &hash,
+                temp,
+                GNUNET_NO,
+                1,
+                edge);
       GNUNET_free (temp);
     }
   }
@@ -3395,12 +3442,27 @@
   {
     for (t = state->transitions_head; NULL != t; t = t->next)
     {
+      if (NULL != strchr (t->label,
+                          (int) '.'))
+      {
+        /* Wildcards not allowed during starting states */
+        GNUNET_break (0);
+        continue;
+      }
       if (NULL != consumed_string)
-        GNUNET_asprintf (&temp, "%s%s", consumed_string, t->label);
+        GNUNET_asprintf (&temp,
+                         "%s%s",
+                         consumed_string,
+                         t->label);
       else
-        GNUNET_asprintf (&temp, "%s", t->label);
-
-      iterate_initial_edge (min_len, max_len, temp, t->to_state, iterator,
+        GNUNET_asprintf (&temp,
+                         "%s",
+                         t->label);
+      iterate_initial_edge (min_len,
+                            max_len,
+                            temp,
+                            t->to_state,
+                            iterator,
                             iterator_cls);
       GNUNET_free (temp);
     }
@@ -3423,6 +3485,14 @@
 {
   struct REGEX_INTERNAL_State *s;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Iterating over starting edges\n");
+  iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES,
+                        GNUNET_REGEX_INITIAL_BYTES,
+                        NULL, a->start,
+                        iterator, iterator_cls);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Iterating over DFA edges\n");
   for (s = a->states_head; NULL != s; s = s->next)
   {
     struct REGEX_BLOCK_Edge edges[s->transition_count];
@@ -3431,18 +3501,20 @@
     num_edges = state_get_edges (s, edges);
     if ( ( (NULL != s->proof) &&
            (0 < strlen (s->proof)) ) || s->accepting)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Creating DFA edges at `%s' under key %s\n",
+                  s->proof,
+                  GNUNET_h2s (&s->hash));
       iterator (iterator_cls, &s->hash, s->proof,
                 s->accepting,
                 num_edges, edges);
+    }
     s->marked = GNUNET_NO;
   }
-
-  iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES,
-                        GNUNET_REGEX_INITIAL_BYTES,
-                        NULL, a->start,
-                        iterator, iterator_cls);
 }
 
+
 /**
  * Struct to hold all the relevant state information in the HashMap.
  *

Modified: gnunet/src/regex/regex_internal_dht.c
===================================================================
--- gnunet/src/regex/regex_internal_dht.c       2015-05-22 12:42:58 UTC (rev 
35787)
+++ gnunet/src/regex/regex_internal_dht.c       2015-05-22 13:26:36 UTC (rev 
35788)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     Copyright (C) 2012 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2015 Christian Grothoff (and other contributing 
authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -34,8 +34,19 @@
 
 #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__)
 
+/**
+ * DHT replication level to use.
+ */
 #define DHT_REPLICATION 5
+
+/**
+ * DHT record lifetime to use.
+ */
 #define DHT_TTL         GNUNET_TIME_UNIT_HOURS
+
+/**
+ * DHT options to set.
+ */
 #define DHT_OPT         GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
 
 
@@ -57,7 +68,7 @@
   /**
    * Automaton representation of the regex (expensive to build).
    */
-  struct REGEX_INTERNAL_Automaton* dfa;
+  struct REGEX_INTERNAL_Automaton *dfa;
 
   /**
    * Our private key.
@@ -77,7 +88,7 @@
  * @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 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.
  */
@@ -95,7 +106,7 @@
   unsigned int i;
 
   LOG (GNUNET_ERROR_TYPE_INFO,
-       "DHT PUT for state %s with proof `%s' and %u edges\n",
+       "DHT PUT for state %s with proof `%s' and %u edges:\n",
        GNUNET_h2s (key),
        proof,
        num_edges);
@@ -102,10 +113,10 @@
   for (i = 0; i < num_edges; i++)
   {
     LOG (GNUNET_ERROR_TYPE_INFO,
-         "  edge %s towards %s (%s)\n",
+         "Edge %u `%s' towards %s\n",
+         i,
          edges[i].label,
-         GNUNET_h2s (&edges[i].destination),
-         proof);
+         GNUNET_h2s (&edges[i].destination));
   }
   if (GNUNET_YES == accepting)
   {
@@ -156,9 +167,11 @@
                   GNUNET_TIME_relative_to_absolute (DHT_TTL),
                   DHT_TTL,
                   NULL, NULL);
-  GNUNET_STATISTICS_update (h->stats, "# regex blocks stored",
+  GNUNET_STATISTICS_update (h->stats,
+                            "# regex blocks stored",
                             1, GNUNET_NO);
-  GNUNET_STATISTICS_update (h->stats, "# regex block bytes stored",
+  GNUNET_STATISTICS_update (h->stats,
+                            "# regex block bytes stored",
                             size, GNUNET_NO);
   GNUNET_free (block);
 }
@@ -166,7 +179,7 @@
 
 /**
  * Announce a regular expression: put all states of the automaton in the DHT.
- * Does not free resources, must call REGEX_INTERNAL_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 priv our private key, must remain valid until the announcement is 
cancelled
@@ -173,9 +186,8 @@
  * @param regex Regular expression to announce.
  * @param compression How many characters per edge can we squeeze?
  * @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_INTERNAL_announce_cancel.
+ *         Must be freed by calling #REGEX_INTERNAL_announce_cancel().
  */
 struct REGEX_INTERNAL_Announcement *
 REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht,
@@ -202,7 +214,7 @@
  * Announce again a regular expression previously announced.
  * Does use caching to speed up process.
  *
- * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
+ * @param h Handle returned by a previous #REGEX_INTERNAL_announce call().
  */
 void
 REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h)
@@ -211,7 +223,9 @@
   LOG (GNUNET_ERROR_TYPE_INFO,
        "REGEX_INTERNAL_reannounce: %s\n",
        h->regex);
-  REGEX_INTERNAL_iterate_reachable_edges (h->dfa, &regex_iterator, h);
+  REGEX_INTERNAL_iterate_reachable_edges (h->dfa,
+                                          &regex_iterator,
+                                          h);
 }
 
 
@@ -219,7 +233,7 @@
  * Clear all cached data used by a regex announce.
  * Does not close DHT connection.
  *
- * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
+ * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call.
  */
 void
 REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h)

Modified: gnunet/src/regex/regex_internal_lib.h
===================================================================
--- gnunet/src/regex/regex_internal_lib.h       2015-05-22 12:42:58 UTC (rev 
35787)
+++ gnunet/src/regex/regex_internal_lib.h       2015-05-22 13:26:36 UTC (rev 
35788)
@@ -61,11 +61,12 @@
  * @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_INTERNAL_automaton_destroy.
+ * @return DFA, needs to be freed using #REGEX_INTERNAL_automaton_destroy().
  */
 struct REGEX_INTERNAL_Automaton *
-REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len,
-                            unsigned int max_path_len);
+REGEX_INTERNAL_construct_dfa (const char *regex,
+                              const size_t len,
+                              unsigned int max_path_len);
 
 
 /**
@@ -88,23 +89,23 @@
  */
 int
 REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a,
-                   const char *string);
+                     const char *string);
 
 
 /**
- * Get the first key for the given 'input_string'. This hashes
- * the first x bits of the 'input_string'.
+ * Get the first key for the given @a input_string. This hashes
+ * the first x bits of the @a input_string.
  *
  * @param input_string string.
- * @param string_len length of the 'input_string'.
+ * @param string_len length of the @a input_string.
  * @param key pointer to where to write the hash code.
- *
- * @return number of bits of 'input_string' that have been consumed
+ * @return number of bits of @a input_string that have been consumed
  *         to construct the key
  */
 size_t
-REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len,
-                            struct GNUNET_HashCode * key);
+REGEX_INTERNAL_get_first_key (const char *input_string,
+                              size_t string_len,
+                              struct GNUNET_HashCode * key);
 
 
 /**
@@ -113,16 +114,17 @@
  * @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 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.
  */
-typedef void (*REGEX_INTERNAL_KeyIterator)(void *cls,
-                                         const struct GNUNET_HashCode *key,
-                                         const char *proof,
-                                         int accepting,
-                                         unsigned int num_edges,
-                                         const struct REGEX_BLOCK_Edge *edges);
+typedef void
+(*REGEX_INTERNAL_KeyIterator)(void *cls,
+                              const struct GNUNET_HashCode *key,
+                              const char *proof,
+                              int accepting,
+                              unsigned int num_edges,
+                              const struct REGEX_BLOCK_Edge *edges);
 
 
 /**
@@ -135,13 +137,13 @@
  */
 void
 REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a,
-                                REGEX_INTERNAL_KeyIterator iterator,
-                                void *iterator_cls);
+                                  REGEX_INTERNAL_KeyIterator iterator,
+                                  void *iterator_cls);
 
 
 /**
  * Iterate over all edges of automaton 'a' that are reachable from a state with
- * a proof of at least GNUNET_REGEX_INITIAL_BYTES characters.
+ * a proof of at least #GNUNET_REGEX_INITIAL_BYTES characters.
  *
  * Call the iterator for each such edge.
  *
@@ -169,7 +171,7 @@
 
 /**
  * Announce a regular expression: put all states of the automaton in the DHT.
- * Does not free resources, must call REGEX_INTERNAL_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 priv our private key, must remain valid until the announcement is 
cancelled
@@ -176,9 +178,8 @@
  * @param regex Regular expression to announce.
  * @param compression How many characters per edge can we squeeze?
  * @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_INTERNAL_announce_cancel.
+ *         Must be freed by calling #REGEX_INTERNAL_announce_cancel().
  */
 struct REGEX_INTERNAL_Announcement *
 REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht,
@@ -192,7 +193,7 @@
  * Announce again a regular expression previously announced.
  * Does use caching to speed up process.
  *
- * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
+ * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call.
  */
 void
 REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h);
@@ -202,7 +203,7 @@
  * Clear all cached data used by a regex announce.
  * Does not close DHT connection.
  *
- * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
+ * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call.
  */
 void
 REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h);
@@ -211,24 +212,25 @@
 /**
  * Search callback function.
  *
- * @param cls Closure provided in REGEX_INTERNAL_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 get_path_length Length of @a get_path.
  * @param put_path Path of the put request.
- * @param put_path_length Length of the put_path.
+ * @param put_path_length Length of the @a put_path.
  */
-typedef void (*REGEX_INTERNAL_Found)(void *cls,
-                                   const struct GNUNET_PeerIdentity *id,
-                                   const struct GNUNET_PeerIdentity *get_path,
-                                   unsigned int get_path_length,
-                                   const struct GNUNET_PeerIdentity *put_path,
-                                   unsigned int put_path_length);
+typedef void
+(*REGEX_INTERNAL_Found)(void *cls,
+                        const struct GNUNET_PeerIdentity *id,
+                        const struct GNUNET_PeerIdentity *get_path,
+                        unsigned int get_path_length,
+                        const struct GNUNET_PeerIdentity *put_path,
+                        unsigned int put_path_length);
 
 
 /**
  * Search for a peer offering a regex matching certain string in the DHT.
- * The search runs until REGEX_INTERNAL_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.
@@ -236,22 +238,21 @@
  * @param callback Callback for found peers.
  * @param callback_cls Closure for @c callback.
  * @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_INTERNAL_search_cancel.
+ *         Must be freed by calling #REGEX_INTERNAL_search_cancel().
  */
 struct REGEX_INTERNAL_Search *
 REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
-                     const char *string,
-                     REGEX_INTERNAL_Found callback,
-                     void *callback_cls,
-                     struct GNUNET_STATISTICS_Handle *stats);
+                       const char *string,
+                       REGEX_INTERNAL_Found callback,
+                       void *callback_cls,
+                       struct GNUNET_STATISTICS_Handle *stats);
 
 /**
- * Stop search and free all data used by a REGEX_INTERNAL_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_INTERNAL_search call.
+ * @param h Handle returned by a previous #REGEX_INTERNAL_search() call.
  */
 void
 REGEX_INTERNAL_search_cancel (struct REGEX_INTERNAL_Search *h);

Modified: gnunet/src/regex/test_regex_integration.c
===================================================================
--- gnunet/src/regex/test_regex_integration.c   2015-05-22 12:42:58 UTC (rev 
35787)
+++ gnunet/src/regex/test_regex_integration.c   2015-05-22 13:26:36 UTC (rev 
35788)
@@ -85,7 +85,7 @@
 /**
  * Search callback function, invoked for every result that was found.
  *
- * @param cls Closure provided in GNUNET_REGEX_search.
+ * @param cls Closure provided in #GNUNET_REGEX_search().
  * @param id Peer providing a regex that matches the string.
  * @param get_path Path of the get request.
  * @param get_path_length Length of @a get_path.
@@ -103,9 +103,9 @@
   const char *str = cls;
   static int found;
 
-  fprintf (stderr,
-           "IPv%s-exit found\n",
-           str);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "IPv%s-exit found\n",
+              str);
   if (0 == strcmp (str, "4"))
     found |= 4;
   if (0 == strcmp (str, "6"))




reply via email to

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