log
[oweals/gnunet.git] / src / scalarproduct / gnunet-scalarproduct.c
index 6f8d03bf354d6fdba599454b5b60effd212a563a..aa894b61d644f44f6a6d6f0af53c2acacd4400ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013, 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013, 2014 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -138,8 +138,7 @@ requester_callback (void *cls,
     {
       ret = 0;
       fprintf (stdout,
-               "%s%s\n",
-               (0 > gcry_mpi_cmp_ui (result, 0)) ? "-" : "",
+               "%s\n",
                buf);
       fflush (stdout);
     }
@@ -185,8 +184,7 @@ requester_callback (void *cls,
  * @param tc unused
  */
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   if (NULL != computation)
   {
@@ -244,13 +242,20 @@ run (void *cls,
          input_peer_id);
     return;
   }
-
+  if ( ('\'' == *begin) &&
+       ('\'' == begin[strlen(begin)-1]) )
+  {
+    begin[strlen(begin)-1] = '\0';
+    if (strlen (begin) > 0)
+      begin++;
+  }
   for (end = begin; 0 != *end; end++)
     if (*end == ';')
       element_count++;
-  if (0 == element_count) {
+  if (0 == element_count)
+  {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Need elements to compute the vectorproduct, got none.\n"));
+         _("Need elements to compute the scalarproduct, got none.\n"));
     return;
   }
 
@@ -277,9 +282,8 @@ run (void *cls,
       GNUNET_free (elements);
       return;
     }
-
-    /* read the element's key */
     *separator = 0;
+    /* read the element's key */
     GNUNET_CRYPTO_hash (begin,
                         strlen (begin),
                         &element.key);
@@ -317,14 +321,14 @@ run (void *cls,
                                                               &responder_callback,
                                                               NULL))) ) )
   {
-    GNUNET_break (0);
+    fprintf (stderr,
+             _("Failed to initiate computation, were all keys unique?\n"));
     GNUNET_free (elements);
     return;
   }
   GNUNET_free (elements);
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
   ret = 0;
 }