Merge branch 'license/spdx'
[oweals/gnunet.git] / src / social / gnunet-social.c
index 7c36a96d4d1fb354d4ed5186657aca3d369c46fe..14701bfda6dc2c930b7ce36abf3dc80ffaddefab 100644 (file)
@@ -2,20 +2,20 @@
      This file is part of GNUnet.
      Copyright (C) 2016 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
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     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., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
@@ -29,7 +29,6 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_social_service.h"
-#include "gnunet_core_service.h"
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
@@ -68,10 +67,10 @@ static int op_guest_leave;
 static int op_guest_talk;
 
 /** --replay */
-static char *op_replay;
+static int op_replay;
 
 /** --replay-latest */
-static char *op_replay_latest;
+static int op_replay_latest;
 
 /** --look-at */
 static int op_look_at;
@@ -117,13 +116,13 @@ static char *opt_data;
 static char *opt_name;
 
 /** --start */
-static uint64_t opt_start;
+static unsigned long long opt_start;
 
 /** --until */
-static uint64_t opt_until;
+static unsigned long long opt_until;
 
 /** --limit */
-static int opt_limit;
+static unsigned long long opt_limit;
 
 
 /* global vars */
@@ -131,12 +130,14 @@ static int opt_limit;
 /** exit code */
 static int ret = 1;
 
+/** are we waiting for service to close our connection */
+static char is_disconnecting = 0;
+
 /** Task handle for timeout termination. */
 struct GNUNET_SCHEDULER_Task *timeout_task;
 
 const struct GNUNET_CONFIGURATION_Handle *cfg;
 
-struct GNUNET_CORE_Handle *core;
 struct GNUNET_PeerIdentity peer, this_peer;
 
 struct GNUNET_SOCIAL_App *app;
@@ -153,6 +154,8 @@ struct GNUNET_SOCIAL_Host *hst;
 struct GNUNET_SOCIAL_Guest *gst;
 struct GNUNET_SOCIAL_Place *plc;
 
+const char *method_received;
+
 
 /* DISCONNECT */
 
@@ -199,8 +202,11 @@ app_disconnected (void *cls)
 static void
 disconnect ()
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect()\n");
-  GNUNET_SOCIAL_app_disconnect (app, app_disconnected, NULL);
+  // handle that we get called several times from several places, but should we?
+  if (!is_disconnecting++) {
+    GNUNET_SOCIAL_app_disconnect (app, app_disconnected, NULL);
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect() called for the #%d time\n", is_disconnecting);
 }
 
 
@@ -275,9 +281,9 @@ exit_fail ()
  * This also indicates the end of the connection to the service.
  */
 static void
-host_left ()
+host_left (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "The host has left the place.\n");
   exit_success ();
 }
@@ -303,8 +309,8 @@ host_leave ()
 static void
 guest_left (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "The guest has left the place.\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+              "Guest has left the place.\n");
 }
 
 
@@ -349,14 +355,14 @@ notify_data (void *cls, uint16_t *data_size, void *data)
   struct TransmitClosure *tmit = cls;
   uint16_t size = tmit->size < *data_size ? tmit->size : *data_size;
   *data_size = size;
-  memcpy (data, tmit->data, size);
+  GNUNET_memcpy (data, tmit->data, size);
 
   tmit->size -= size;
   tmit->data += size;
 
   if (0 == tmit->size)
   {
-    if (op_host_announce || op_host_assign || op_guest_talk)
+    if ((op_host_announce || op_host_assign || op_guest_talk) && !opt_follow)
     {
       exit_success ();
     }
@@ -512,7 +518,7 @@ look_var (void *cls,
           uint32_t value_size,
           uint32_t full_value_size)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Received var: %s\n%.*s\n",
               name, value_size, (const char *) value);
 }
@@ -551,10 +557,15 @@ slicer_recv_method (void *cls,
                     uint64_t message_id,
                     const char *method_name)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  method_received = method_name;
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Received method for message ID %" PRIu64 ":\n"
               "%s (flags: %x)\n",
               message_id, method_name, ntohl (meth->flags));
+  /* routing header is missing, so we just print double newline */
+  printf("\n");
+  /* we output . instead of | to indicate that this is not proper PSYC syntax */
+  /* FIXME: use libpsyc here */
 }
 
 
@@ -572,10 +583,16 @@ slicer_recv_modifier (void *cls,
                       uint16_t value_size,
                       uint16_t full_value_size)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+#if 0
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Received modifier for message ID %" PRIu64 ":\n"
               "%c%s: %.*s (size: %u)\n",
               message_id, oper, name, value_size, (const char *) value, value_size);
+#else
+  /* obviously not binary safe */
+  printf("%c%s\t%.*s\n",
+              oper, name, value_size, (const char *) value);
+#endif
 }
 
 
@@ -590,10 +607,16 @@ slicer_recv_data (void *cls,
                   const void *data,
                   uint16_t data_size)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+#if 0
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Received data for message ID %" PRIu64 ":\n"
               "%.*s\n",
               message_id, data_size, (const char *) data);
+#else
+  /* obviously not binary safe */
+  printf("%s\n%.*s\n",
+              method_received, data_size, (const char *) data);
+#endif
 }
 
 
@@ -607,7 +630,8 @@ slicer_recv_eom (void *cls,
                 uint64_t message_id,
                 uint8_t is_cancelled)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  printf(".\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Received end of message ID %" PRIu64
               ", cancelled: %u\n",
               message_id, is_cancelled);
@@ -644,7 +668,7 @@ guest_recv_entry_decision (void *cls,
                            int is_admitted,
                            const struct GNUNET_PSYC_Message *entry_msg)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Guest received entry decision %d\n",
               is_admitted);
 
@@ -659,7 +683,7 @@ guest_recv_entry_decision (void *cls,
     GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
     GNUNET_free (pmsg);
 
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
                 "%s\n%.*s\n",
                 method_name, data_size, (const char *) data);
   }
@@ -680,8 +704,8 @@ guest_recv_local_enter (void *cls, int result,
                         uint64_t max_message_id)
 {
   char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key);
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Guest entered to local place: %s, max_message_id: %" PRIu64 "\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+              "Guest entered local place: %s, max_message_id: %" PRIu64 "\n",
               pub_str, max_message_id);
   GNUNET_free (pub_str);
   GNUNET_assert (0 <= result);
@@ -694,7 +718,7 @@ guest_recv_local_enter (void *cls, int result,
 
 
 /**
- * Create entry requset message.
+ * Create entry request message.
  */
 static struct GNUNET_PSYC_Message *
 guest_enter_msg_create ()
@@ -727,12 +751,13 @@ guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
     return;
   }
 
+  struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create ();
   gst = GNUNET_SOCIAL_guest_enter (app, ego, pub_key,
                                    GNUNET_PSYC_SLAVE_JOIN_NONE,
-                                   peer, 0, NULL, guest_enter_msg_create (),
-                                   slicer_create (),
+                                   peer, 0, NULL, join_msg, slicer_create (),
                                    guest_recv_local_enter,
                                    guest_recv_entry_decision, NULL);
+  GNUNET_free (join_msg);
   plc = GNUNET_SOCIAL_guest_get_place (gst);
 }
 
@@ -746,10 +771,12 @@ guest_enter_by_name (const char *gns_name)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Entering to place by name as guest.\n");
 
+  struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create ();
   gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL,
-                                           guest_enter_msg_create (), slicer,
+                                           join_msg, slicer,
                                            guest_recv_local_enter,
                                            guest_recv_entry_decision, NULL);
+  GNUNET_free (join_msg);
   plc = GNUNET_SOCIAL_guest_get_place (gst);
 }
 
@@ -775,7 +802,7 @@ host_answer_door (void *cls,
   char *
     nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Entry request: %s\n", nym_str);
   GNUNET_free (nym_str);
 
@@ -813,7 +840,7 @@ host_farewell (void *cls,
   char *
     nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Farewell: %s\n", nym_str);
   GNUNET_free (nym_str);
 }
@@ -829,7 +856,7 @@ host_entered (void *cls, int result,
 {
   place_pub_key = *pub_key;
   char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key);
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "Host entered: %s, max_message_id: %" PRIu64 "\n",
               pub_str, max_message_id);
   GNUNET_free (pub_str);
@@ -927,8 +954,10 @@ guest_reconnected (void *cls, int result,
                    const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
                    uint64_t max_message_id)
 {
+  char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (place_pub_key);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Guest reconnected.\n");
+              "Guest reconnected to place %s.\n", place_pub_str);
+  GNUNET_free (place_pub_str);
 
   if (op_guest_leave) {
     guest_leave ();
@@ -989,6 +1018,7 @@ app_connected (void *cls)
       guest_enter (&place_pub_key, &peer);
     }
   }
+  printf(".\n");
 }
 
 
@@ -1003,8 +1033,7 @@ app_recv_host (void *cls,
                enum GNUNET_SOCIAL_AppPlaceState place_state)
 {
   char *host_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (host_pub_key);
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Host:  %s\n", host_pub_str);
+  printf ("Host\t%s\n", host_pub_str);
   GNUNET_free (host_pub_str);
 
   if ((op_host_reconnect || op_host_leave || op_host_announce || op_host_assign
@@ -1030,8 +1059,7 @@ app_recv_guest (void *cls,
                 enum GNUNET_SOCIAL_AppPlaceState place_state)
 {
   char *guest_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (guest_pub_key);
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Guest: %s\n", guest_pub_str);
+  printf ("Guest\t%s\n", guest_pub_str);
   GNUNET_free (guest_pub_str);
 
   if ((op_guest_reconnect || op_guest_leave || op_guest_talk
@@ -1055,9 +1083,9 @@ app_recv_ego (void *cls,
               const struct GNUNET_CRYPTO_EcdsaPublicKey *pub_key,
               const char *name)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Ego:   %s\t%s\n",
-              GNUNET_CRYPTO_ecdsa_public_key_to_string (pub_key), name);
+  char *s = GNUNET_CRYPTO_ecdsa_public_key_to_string (pub_key);
+  printf ("Ego\t%s\t%s\n", s, name);
+  GNUNET_free (s);
 
   if (0 == memcmp (&ego_pub_key, pub_key, sizeof (*pub_key))
       || (NULL != opt_ego && 0 == strcmp (opt_ego, name)))
@@ -1075,9 +1103,6 @@ app_recv_ego (void *cls,
 static void
 app_connect (void *cls)
 {
-  GNUNET_CORE_disconnect (core);
-  core = NULL;
-
   app = GNUNET_SOCIAL_app_connect (cfg, opt_app,
                                    app_recv_ego,
                                    app_recv_host,
@@ -1087,33 +1112,20 @@ app_connect (void *cls)
 }
 
 
-/* CORE */
-
-
-static void
-core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
-{
-  this_peer = *my_identity;
-  GNUNET_SCHEDULER_add_now (app_connect, NULL);
-}
-
-
-/* RUN */
-
-
 /**
  * Main function run by the scheduler.
  *
  * @param cls closure
  * @param args remaining command-line arguments
  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg configuration
+ * @param c configuration
  */
 static void
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   cfg = c;
+  GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer);
 
   if (!opt_method)
     opt_method = "message";
@@ -1131,6 +1143,7 @@ run (void *cls, char *const *args, const char *cfgfile,
          || op_look_at || op_look_for))
   {
     op_status = 1;
+    fputs("Caution: This tool does not produce correct binary safe PSYC syntax.\n\n", stderr);
   }
 
   GNUNET_SCHEDULER_add_shutdown (scheduler_shutdown, NULL);
@@ -1151,19 +1164,27 @@ run (void *cls, char *const *args, const char *cfgfile,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 _("--place missing or invalid.\n"));
+    /* FIXME: why does it segfault here? */
     exit_fail ();
     return;
   }
 
   if (opt_ego)
   {
-    GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
+    if (GNUNET_OK !=
+        GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
                                                 strlen (opt_ego),
-                                                &ego_pub_key);
+                                                &ego_pub_key))
+    {
+      FPRINTF (stderr,
+               _("Public key `%s' malformed\n"),
+               opt_ego);
+      exit_fail ();
+      return;
+    }
   }
 
-  core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL,
-                              NULL, GNUNET_NO, NULL, GNUNET_NO, NULL);
+  GNUNET_SCHEDULER_add_now (app_connect, NULL);
 }
 
 
@@ -1178,7 +1199,7 @@ int
 main (int argc, char *const *argv)
 {
   int res;
-  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
     /*
      * gnunet program options in addition to the ones below:
      *
@@ -1191,120 +1212,160 @@ main (int argc, char *const *argv)
 
     /* operations */
 
-    { 'A', "host-assign", NULL,
-      gettext_noop ("assign --name in state to --data"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_assign },
-
-    { 'B', "guest-leave", NULL,
-      gettext_noop ("say good-bye and leave somebody else's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave },
-
-    { 'C', "host-enter", NULL,
-      gettext_noop ("create a place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter },
-
-    { 'D', "host-leave", NULL,
-      gettext_noop ("destroy a place we were hosting"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave },
-
-    { 'E', "guest-enter", NULL,
-      gettext_noop ("enter somebody else's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter },
-
-    { 'F', "look-for", NULL,
-      gettext_noop ("find state matching name prefix"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for },
-
-    { 'H', "replay-latest", NULL,
-      gettext_noop ("replay history of messages up to the given --limit"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay_latest },
-
-    { 'N', "host-reconnect", NULL,
-      gettext_noop ("reconnect to a previously created place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect },
-
-    { 'P', "host-announce", NULL,
-      gettext_noop ("publish something to a place we are hosting"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce },
-
-    { 'R', "guest-reconnect", NULL,
-      gettext_noop ("reconnect to a previously entered place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect },
-
-    { 'S', "look-at", NULL,
-      gettext_noop ("search for state matching exact name"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at },
-
-    { 'T', "guest-talk", NULL,
-      gettext_noop ("submit something to somebody's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk },
-
-    { 'U', "status", NULL,
-      gettext_noop ("list of egos and subscribed places"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status },
-
-    { 'X', "replay", NULL,
-      gettext_noop ("extract and replay history between message IDs --start and --until"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay },
+    GNUNET_GETOPT_option_flag ('A',
+                                  "host-assign",
+                                  gettext_noop ("assign --name in state to --data"),
+                                  &op_host_assign),
+
+    GNUNET_GETOPT_option_flag ('B',
+                                  "guest-leave",
+                                  gettext_noop ("say good-bye and leave somebody else's place"),
+                                  &op_guest_leave),
+
+    GNUNET_GETOPT_option_flag ('C',
+                                  "host-enter",
+                                  gettext_noop ("create a place"),
+                                  &op_host_enter),
+
+    GNUNET_GETOPT_option_flag ('D',
+                                  "host-leave",
+                                  gettext_noop ("destroy a place we were hosting"),
+                                  &op_host_leave),
+
+    GNUNET_GETOPT_option_flag ('E',
+                                  "guest-enter",
+                                  gettext_noop ("enter somebody else's place"),
+                                  &op_guest_enter),
+
+
+    GNUNET_GETOPT_option_flag ('F',
+                                  "look-for",
+                                  gettext_noop ("find state matching name prefix"),
+                                  &op_look_for),
+
+    GNUNET_GETOPT_option_flag ('H',
+                                  "replay-latest",
+                                  gettext_noop ("replay history of messages up to the given --limit"),
+                                  &op_replay_latest),
+
+    GNUNET_GETOPT_option_flag ('N',
+                                  "host-reconnect",
+                                  gettext_noop ("reconnect to a previously created place"),
+                                  &op_host_reconnect),
+
+    GNUNET_GETOPT_option_flag ('P',
+                                  "host-announce",
+                                  gettext_noop ("publish something to a place we are hosting"),
+                                  &op_host_announce),
+
+    GNUNET_GETOPT_option_flag ('R',
+                                  "guest-reconnect",
+                                  gettext_noop ("reconnect to a previously entered place"),
+                                  &op_guest_reconnect),
+
+    GNUNET_GETOPT_option_flag ('S',
+                                  "look-at",
+                                  gettext_noop ("search for state matching exact name"),
+                                  &op_look_at),
+
+    GNUNET_GETOPT_option_flag ('T',
+                                  "guest-talk",
+                                  gettext_noop ("submit something to somebody's place"),
+                                  &op_guest_talk),
+
+    GNUNET_GETOPT_option_flag ('U',
+                                  "status",
+                                  gettext_noop ("list of egos and subscribed places"),
+                                  &op_status),
+
+    GNUNET_GETOPT_option_flag ('X',
+                                  "replay",
+                                  gettext_noop ("extract and replay history between message IDs --start and --until"),
+                                  &op_replay),
 
 
     /* options */
 
-    { 'a', "app", "APPLICATION_ID",
-      gettext_noop ("application ID to use when connecting"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app },
-
-    { 'd', "data", "DATA",
-      gettext_noop ("message body or state value"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_data },
-
-    { 'e', "ego", "NAME|PUBKEY",
-      gettext_noop ("name or public key of ego"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego },
-
-    { 'f', "follow", NULL,
-      gettext_noop ("wait for incoming messages"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow },
-
-    { 'g', "gns", "GNS_NAME",
-      gettext_noop ("GNS name"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns },
-
-    { 'i', "peer", "PEER_ID",
-      gettext_noop ("peer ID for --guest-enter"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer },
-
-    { 'k', "name", "VAR_NAME",
-      gettext_noop ("name (key) to query from state"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name },
-
-    { 'm', "method", "METHOD_NAME",
-      gettext_noop ("method name"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method },
-
-    { 'n', "limit", NULL,
-      gettext_noop ("number of messages to replay from history"),
-      GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit },
-
-    { 'p', "place", "PUBKEY",
-      gettext_noop ("key address of place"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place },
-
-    { 's', "start", NULL,
-      gettext_noop ("start message ID for history replay"),
-      GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start },
-
-    { 'w', "welcome", NULL,
-      gettext_noop ("respond to entry requests by admitting all guests"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_welcome },
-
-    { 'u', "until", NULL,
-      gettext_noop ("end message ID for history replay"),
-      GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_until },
-
-    { 'y', "deny", NULL,
-      gettext_noop ("respond to entry requests by refusing all guests"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_deny },
+    GNUNET_GETOPT_option_string ('a',
+                                 "app",
+                                 "APPLICATION_ID",
+                                 gettext_noop ("application ID to use when connecting"),
+                                 &opt_app),
+
+    GNUNET_GETOPT_option_string ('d',
+                                 "data",
+                                 "DATA",
+                                 gettext_noop ("message body or state value"),
+                                 &opt_data),
+
+    GNUNET_GETOPT_option_string ('e',
+                                 "ego",
+                                 "NAME|PUBKEY",
+                                 gettext_noop ("name or public key of ego"),
+                                 &opt_ego),
+
+    GNUNET_GETOPT_option_flag ('f',
+                                  "follow",
+                                  gettext_noop ("wait for incoming messages"),
+                                  &opt_follow),
+
+    GNUNET_GETOPT_option_string ('g',
+                                 "gns",
+                                 "GNS_NAME",
+                                 gettext_noop ("GNS name"),
+                                 &opt_gns),
+
+    GNUNET_GETOPT_option_string ('i',
+                                 "peer",
+                                 "PEER_ID",
+                                 gettext_noop ("peer ID for --guest-enter"),
+                                 &opt_peer),
+
+    GNUNET_GETOPT_option_string ('k',
+                                 "name",
+                                 "VAR_NAME",
+                                 gettext_noop ("name (key) to query from state"),
+                                 &opt_name),
+
+    GNUNET_GETOPT_option_string ('m',
+                                 "method",
+                                 "METHOD_NAME",
+                                 gettext_noop ("method name"),
+                                 &opt_method),
+
+    GNUNET_GETOPT_option_ulong ('n',
+                                    "limit",
+                                    NULL,
+                                    gettext_noop ("number of messages to replay from history"),
+                                    &opt_limit),
+
+    GNUNET_GETOPT_option_string ('p',
+                                 "place",
+                                 "PUBKEY",
+                                 gettext_noop ("key address of place"),
+                                 &opt_place),
+
+    GNUNET_GETOPT_option_ulong ('s',
+                                    "start",
+                                    NULL,
+                                    gettext_noop ("start message ID for history replay"),
+                                    &opt_start),
+
+    GNUNET_GETOPT_option_flag ('w',
+                                  "welcome",
+                                  gettext_noop ("respond to entry requests by admitting all guests"),
+                                  &opt_welcome),
+
+    GNUNET_GETOPT_option_ulong ('u',
+                                    "until",
+                                    NULL,
+                                    gettext_noop ("end message ID for history replay"),
+                                    &opt_until),
+
+    GNUNET_GETOPT_option_flag ('y',
+                                  "deny",
+                                  gettext_noop ("respond to entry requests by refusing all guests"),
+                                  &opt_deny),
 
     GNUNET_GETOPT_OPTION_END
   };
@@ -1333,8 +1394,8 @@ main (int argc, char *const *argv)
     "gnunet-social --guest-leave --place <PUBKEY>\n"
     "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NAME> --data <MESSAGE_BODY>\n"
     "\n"
-    "gnunet-social --history-replay --place <PUBKEY> --start <MSGID> --until <MSGID>  [--method <METHOD_PREFIX>]\n"
-    "gnunet-social --history-replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n"
+    "gnunet-social --replay --place <PUBKEY> --start <MSGID> --until <MSGID>  [--method <METHOD_PREFIX>]\n"
+    "gnunet-social --replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n"
     "\n"
     "gnunet-social --look-at --place <PUBKEY> --name <FULL_NAME>\n"
     "gnunet-social --look-for --place <PUBKEY> --name <NAME_PREFIX>\n";