add completion callback for overlay topology configure functions
[oweals/gnunet.git] / src / regex / plugin_block_regex.c
index 9a5ab33ecffc4322c8ffa4797c5a6f9a7870ec9c..d3c973560355a40248300a71d381ff418b65a620 100644 (file)
 #define BLOOMFILTER_K 16
 
 
+/**
+ * Show debug info about outgoing edges from a block.
+ * 
+ * @param cls Closure (uunsed).
+ * @param token Edge label.
+ * @param len Length of @c token.
+ * @param key Block the edge point to.
+ * 
+ * @return GNUNET_YES to keep iterating.
+ */
+static int
+rdebug (void *cls,
+             const char *token,
+             size_t len,
+             const struct GNUNET_HashCode *key)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    %s: %.*s\n",
+              GNUNET_h2s (key), len, token);
+  return GNUNET_YES;
+}
+
+
 /**
  * Function called to validate a reply or a request.  For
  * request evaluation, simply pass "NULL" for the reply_block.
@@ -84,7 +106,13 @@ block_plugin_regex_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
       }
       else
       {
+        const struct RegexBlock *rblock = reply_block;
+
         GNUNET_break_op (0);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Block with no xquery\n");
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  key: %s, %u edges\n",
+                    GNUNET_h2s (&rblock->key), ntohl (rblock->n_edges));
+        GNUNET_REGEX_block_iterate (rblock, reply_block_size, &rdebug, NULL);
         return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
       }
       switch (GNUNET_REGEX_block_check (reply_block,
@@ -176,10 +204,17 @@ block_plugin_regex_get_key (void *cls, enum GNUNET_BLOCK_Type type,
 {
   switch (type)
   {
-  default:
-    /* FIXME */
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
+    case GNUNET_BLOCK_TYPE_REGEX:
+      GNUNET_assert (sizeof (struct RegexBlock) <= block_size);
+      *key = ((struct RegexBlock *) block)->key;
+      return GNUNET_OK;
+    case GNUNET_BLOCK_TYPE_REGEX_ACCEPT:
+      GNUNET_assert (sizeof (struct RegexAccept) <= block_size);
+      *key = ((struct RegexAccept *) block)->key;
+      return GNUNET_OK;
+    default:
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
   }
 }