gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: use modern getopt api


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: use modern getopt api
Date: Sun, 19 Mar 2017 01:00:58 +0100

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new d538d98c1 use modern getopt api
d538d98c1 is described below

commit d538d98c19a58a4f0ab55826a873f1fd86fa5372
Author: Julius Bünger <address@hidden>
AuthorDate: Sun Mar 19 00:59:35 2017 +0100

    use modern getopt api
---
 src/rps/gnunet-rps.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index d82528182..f6bc94eca 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -41,9 +41,9 @@ static struct GNUNET_RPS_Handle *rps_handle;
 static struct GNUNET_RPS_Request_Handle *req_handle;
 
 /**
- * PeerID in string representation (Option --seed)
+ * PeerID (Option --seed)
  */
-static char *peer_id_str;
+static struct GNUNET_PeerIdentity peer_id;
 
 
 /**
@@ -103,11 +103,13 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   static uint64_t num_peers;
-  struct GNUNET_PeerIdentity peer_id;
+  struct GNUNET_PeerIdentity zero_pid;
 
   rps_handle = GNUNET_RPS_connect (cfg);
 
-  if (NULL == peer_id_str)
+  if (0 == memcmp (&zero_pid,
+                   &peer_id,
+                   sizeof (peer_id)))
   { /* Request n PeerIDs */
     /* If number was specified use it, else request single peer. */
     num_peers = (NULL == args[0]) ? 1 : atoi (args[0]);
@@ -118,16 +120,6 @@ run (void *cls,
   }
   else
   { /* Seed PeerID */
-    if (GNUNET_OK !=
-        GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id_str,
-                                                    strlen (peer_id_str),
-                                                    &peer_id.public_key))
-    {
-      FPRINTF (stderr,
-               _("Failed to parse peer identity `%s'\n"),
-               peer_id_str);
-      return;
-    }
     GNUNET_RPS_seed_ids (rps_handle, 1, &peer_id);
     FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (&peer_id));
     ret = 0;
@@ -148,11 +140,11 @@ main (int argc, char *const *argv)
   const char helpstr[] =
     "Get random GNUnet peers. If none is specified a single is requested.";
   struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_STRING ('s',
-                                 "seed",
-                                 "PEER_ID",
-                                 gettext_noop ("Seed a PeerID"),
-                                 &peer_id_str),
+    GNUNET_GETOPT_OPTION_SET_BASE32_AUTO ('s',
+                                          "seed",
+                                          "PEER_ID",
+                                          gettext_noop ("Seed a PeerID"),
+                                          &peer_id),
     GNUNET_GETOPT_OPTION_END
   };
   return (GNUNET_OK ==

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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