print active/inactive information
[oweals/gnunet.git] / src / regex / plugin_block_regex.c
index 317f65d8da7bea50fb86496054a53e6642c3abe4..43ebe7b3237568e789c863119c1262be10907144 100644 (file)
@@ -60,35 +60,37 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type,
                       size_t reply_block_size)
 {
   if (NULL == reply_block)
-    {
-      if (0 != xquery_size)
-       {
-         const char *s;  
-         
-         s = (const char *) xquery;
-         if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
-           {
-             GNUNET_break_op (0);
-             return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-           }
-       }
-      return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
-    }
+  {
+    if (0 != xquery_size)
+      {
+        const char *s;
+
+        s = (const char *) xquery;
+        if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
+          {
+            GNUNET_break_op (0);
+            return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
+          }
+      }
+    return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+  }
   if (0 != xquery_size)
   {
-    const char *query;
+    const char *s;
 
-    query = (const char *) xquery;
-    if ('\0' != query[xquery_size - 1]) /* must be valid 0-terminated string */
+    s = (const char *) xquery;
+    if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
     {
       GNUNET_break_op (0);
       return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
     }
   }
-  else 
+  else if (NULL != query)
   {
-    /* xquery is required for regex, at least an empty string */
+    /* xquery is required for regex GETs, at least an empty string */
     GNUNET_break_op (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "type %d, query %p, xquery %p\n",
+                type, query, xquery);
     return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
   }
   switch (REGEX_BLOCK_check (reply_block,
@@ -172,22 +174,22 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
   if (ntohl (rba->purpose.size) !=
       sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
       sizeof (struct GNUNET_TIME_AbsoluteNBO) +
-      sizeof (struct GNUNET_HashCode)) 
+      sizeof (struct GNUNET_HashCode))
   {
     GNUNET_break_op(0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
   }
-  if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rba->expiration_time)).rel_value)
+  if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rba->expiration_time)).rel_value_us)
   {
     /* technically invalid, but can happen without an error, so
        we're nice by reporting it as a 'duplicate' */
     return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
-  }  
+  }
   if (GNUNET_OK !=
-      GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT,
+      GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT,
                                &rba->purpose,
                                &rba->signature,
-                               &rba->public_key))
+                               &rba->peer.public_key))
   {
     GNUNET_break_op(0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
@@ -268,9 +270,9 @@ block_plugin_regex_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
  * @param cls closure
  * @param type block type
  * @param block block to get the key for
- * @param block_size number of bytes in block
+ * @param block_size number of bytes in @a block
  * @param key set to the key (query) for the given block
- * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
  *         (or if extracting a key from a block of this type does not work)
  */
 static int
@@ -318,7 +320,7 @@ libgnunet_plugin_block_regex_init (void *cls)
   };
   struct GNUNET_BLOCK_PluginFunctions *api;
 
-  api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions));
+  api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
   api->evaluate = &block_plugin_regex_evaluate;
   api->get_key = &block_plugin_regex_get_key;
   api->types = types;