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
*/
/**
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;
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 */
* 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 ();
}
static void
guest_left (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Guest has left the place.\n");
}
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);
}
const char *method_name)
{
method_received = method_name;
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Received method for message ID %" PRIu64 ":\n"
"%s (flags: %x)\n",
message_id, method_name, ntohl (meth->flags));
uint16_t full_value_size)
{
#if 0
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ 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);
uint16_t data_size)
{
#if 0
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Received data for message ID %" PRIu64 ":\n"
"%.*s\n",
message_id, data_size, (const char *) data);
uint8_t is_cancelled)
{
printf(".\n");
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Received end of message ID %" PRIu64
", cancelled: %u\n",
message_id, is_cancelled);
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);
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);
}
uint64_t max_message_id)
{
char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ 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);
/**
- * Create entry requset message.
+ * Create entry request message.
*/
static struct GNUNET_PSYC_Message *
guest_enter_msg_create ()
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);
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);
}
{
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);
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:
*
/* 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
};