2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * CLI tool to interact with the social service.
24 * @author Gabor X Toth
30 #include "gnunet_util_lib.h"
31 #include "gnunet_social_service.h"
33 /* operations corresponding to API calls */
36 static int op_host_enter;
39 static int op_host_leave;
41 /** --host-announce */
42 static int op_host_announce;
45 static int op_guest_enter;
48 static int op_guest_leave;
51 static int op_guest_talk;
53 /** --history-replay */
54 static char *op_history_replay;
56 /** --history-replay-latest */
57 static char *op_history_replay_latest;
65 static int flag_listen;
77 static uint64_t start;
87 * Main function that will be run by the scheduler.
90 * @param args remaining command-line arguments
91 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
92 * @param cfg configuration
95 run (void *cls, char *const *args, const char *cfgfile,
96 const struct GNUNET_CONFIGURATION_Handle *cfg)
98 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TODO\n");
103 * The main function to obtain peer information.
105 * @param argc number of arguments from the command line
106 * @param argv command line arguments
107 * @return 0 ok, 1 on error
110 main (int argc, char *const *argv)
113 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
114 {'p', "place", "PUBKEY",
115 gettext_noop ("public key of place"),
116 GNUNET_YES, &GNUNET_GETOPT_set_string, &place},
118 {'l', "listen", NULL,
119 gettext_noop ("listen for incoming messages"),
120 GNUNET_NO, &GNUNET_GETOPT_set_one, &flag_listen},
122 {'m', "method", "METHOD_NAME",
123 gettext_noop ("method name to transmit"),
124 GNUNET_YES, &GNUNET_GETOPT_set_string, &method},
126 {'d', "data", "DATA",
127 gettext_noop ("message body to transmit"),
128 GNUNET_YES, &GNUNET_GETOPT_set_string, &data},
130 {'p', "prefix", "METHOD_PREFIX",
131 gettext_noop ("method prefix filter for history replay"),
132 GNUNET_YES, &GNUNET_GETOPT_set_string, &prefix},
135 gettext_noop ("start message ID for history replay"),
136 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &start},
139 gettext_noop ("end message ID for history replay"),
140 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &end},
143 gettext_noop ("number of messages to replay from history"),
144 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &limit},
146 {'C', "host-enter", NULL,
147 gettext_noop ("create a place for nyms to join"),
148 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter},
151 /** --host-announce */
155 /** --history-replay */
156 /** --history-replay-latest */
158 GNUNET_GETOPT_OPTION_END
161 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
165 "enter/leave and send/receive messages in places of the social service";
167 "gnunet-social --host-enter [--listen]\n"
168 "gnunet-social --place <pubkey> --host-leave\n"
169 "gnunet-social --place <pubkey> --host-announce --method <method_name> --data <message_body>\n"
171 "gnunet-social --place <pubkey> --guest-enter [--listen]\n"
172 "gnunet-social --place <pubkey> --guest-leave\n"
173 "gnunet-social --place <pubkey> --guest-talk --method <method_nmae> --data <data>\n"
175 "gnunet-social --place <pubkey> --history-replay --start <msgid> --end <msgid> [--prefix <method_prefix>]\n"
176 "gnunet-social --place <pubkey> --history-replay-latest --limit <msg_limit> [--prefix <method_prefix>]\n"
178 "gnunet-social --place <pubkey> --look-at <full_name>\n"
179 "gnunet-social --place <pubkey> --look-for <name_prefix>\n";
181 res = GNUNET_PROGRAM_run (argc, argv, usage,
183 options, &run, NULL);
185 GNUNET_free ((void *) argv);
187 if (GNUNET_OK == res)