/**
* Do we want to give our stdout to gnunet-service-arm?
*/
-static unsigned int no_stdout;
+static int no_stdout;
/**
* Do we want to give our stderr to gnunet-service-arm?
*/
-static unsigned int no_stderr;
+static int no_stderr;
/**
* Handle for the task running the #action_loop().
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'e', "end", NULL, gettext_noop ("stop all GNUnet services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &end},
- {'i', "init", "SERVICE", gettext_noop ("start a particular service"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &init},
- {'k', "kill", "SERVICE", gettext_noop ("stop a particular service"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &term},
- {'s', "start", NULL, gettext_noop ("start all GNUnet default services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &start},
- {'r', "restart", NULL,
- gettext_noop ("stop and start all GNUnet default services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &restart},
- {'d', "delete", NULL,
- gettext_noop ("delete config file and directory on exit"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &delete},
- {'m', "monitor", NULL,
- gettext_noop ("monitor ARM activities"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor},
- {'q', "quiet", NULL, gettext_noop ("don't print status messages"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet},
- {'T', "timeout", "DELAY",
- gettext_noop ("exit with error status if operation does not finish after DELAY"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout},
- {'I', "info", NULL, gettext_noop ("list currently running services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &list},
- {'O', "no-stdout", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard output"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stdout},
- {'E', "no-stderr", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard error"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stderr},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "end",
+ gettext_noop ("stop all GNUnet services"),
+ &end),
+
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "init",
+ "SERVICE",
+ gettext_noop ("start a particular service"),
+ &init),
+
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "kill",
+ "SERVICE",
+ gettext_noop ("stop a particular service"),
+ &term),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "start",
+ gettext_noop ("start all GNUnet default services"),
+ &start),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('r',
+ "restart",
+ gettext_noop ("stop and start all GNUnet default services"),
+ &restart),
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "delete",
+ gettext_noop ("delete config file and directory on exit"),
+ &delete),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("monitor ARM activities"),
+ &monitor),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('q',
+ "quiet",
+ gettext_noop ("don't print status messages"),
+ &quiet),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T',
+ "timeout",
+ "DELAY",
+ gettext_noop ("exit with error status if operation does not finish after DELAY"),
+ &timeout),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('I',
+ "info",
+ gettext_noop ("list currently running services"),
+ &list),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('O',
+ "no-stdout",
+ gettext_noop ("don't let gnunet-service-arm inherit standard output"),
+ &no_stdout),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('E',
+ "no-stderr",
+ gettext_noop ("don't let gnunet-service-arm inherit standard error"),
+ &no_stderr),
+
GNUNET_GETOPT_OPTION_END
};
opt_log = GNUNET_NO;
opt_plot = GNUNET_NO;
- static struct GNUNET_GETOPT_CommandLineOption options[] =
- {
- { 's', "solver", NULL,
- gettext_noop ("solver to use"),
- 1, &GNUNET_GETOPT_set_string, &opt_solver},
- { 'e', "experiment", NULL,
- gettext_noop ("experiment to use"),
- 1, &GNUNET_GETOPT_set_string, &opt_exp_file},
- { 'e', "experiment", NULL,
- gettext_noop ("experiment to use"),
- 1, &GNUNET_GETOPT_set_one, &opt_verbose},
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "solver",
+ NULL,
+ gettext_noop ("solver to use"),
+ &opt_solver),
+
+ GNUNET_GETOPT_OPTION_STRING ('e',
+ "experiment",
+ NULL,
+ gettext_noop ("experiment to use"),
+ &opt_exp_file),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "experiment",
+ gettext_noop ("experiment to use"),
+ &opt_verbose),
GNUNET_GETOPT_OPTION_END
};
stat_receive_done = GNUNET_NO;
opt_type_str = NULL;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'u', "used", NULL,
- gettext_noop ("get list of active addresses currently used"), 0,
- &GNUNET_GETOPT_set_one, &opt_list_used },
- { 'a', "all", NULL, gettext_noop ("get list of all active addresses"), 0,
- &GNUNET_GETOPT_set_one, &opt_list_all },
- { 'C', "connect", "PEER",
- gettext_noop ("connect to PEER"), 1,
- &GNUNET_GETOPT_set_string, &cpid_str },
- { 'n', "numeric", NULL,
- gettext_noop ("do not resolve IP addresses to hostnames"), 0,
- &GNUNET_GETOPT_set_one, &opt_resolve_addresses_numeric },
- { 'm', "monitor", NULL, gettext_noop ("monitor mode"), 0,
- &GNUNET_GETOPT_set_one, &opt_monitor },
- { 'p', "preference", NULL, gettext_noop ("set preference for the given peer"),
- 0, &GNUNET_GETOPT_set_one, &opt_set_pref },
- { 'q', "quotas", NULL, gettext_noop ("print all configured quotas"), 0,
- &GNUNET_GETOPT_set_one, &opt_print_quotas },
- { 'i', "id", "TYPE", gettext_noop ("peer id"), 1, &GNUNET_GETOPT_set_string,
- &opt_pid_str },
- { 't', "type", "TYPE",
- gettext_noop ("preference type to set: latency | bandwidth"), 1,
- &GNUNET_GETOPT_set_string, &opt_type_str },
- { 'k', "value", "VALUE", gettext_noop ("preference value"), 1,
- &GNUNET_GETOPT_set_uint, &opt_pref_value },
- { 'V', "verbose", NULL,
- gettext_noop ("verbose output (include ATS address properties)"), 0,
- &GNUNET_GETOPT_set_one, &opt_verbose },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "used",
+ gettext_noop ("get list of active addresses currently used"),
+ &opt_list_used),
+ GNUNET_GETOPT_OPTION_SET_ONE ('a',
+ "all",
+ gettext_noop ("get list of all active addresses"),
+ &opt_list_all),
+
+ GNUNET_GETOPT_OPTION_STRING ('C',
+ "connect",
+ NULL,
+ gettext_noop ("connect to PEER"),
+ &cpid_str),
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "numeric",
+ gettext_noop ("do not resolve IP addresses to hostnames"),
+ &opt_resolve_addresses_numeric),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("monitor mode"),
+ &opt_monitor),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "preference",
+ gettext_noop ("set preference for the given peer"),
+ &opt_set_pref),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('q',
+ "quotas",
+ gettext_noop ("print all configured quotas"),
+ &opt_print_quotas),
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "id",
+ "TYPE",
+ gettext_noop ("peer id"),
+ &opt_pid_str),
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("preference type to set: latency | bandwidth"),
+ &opt_type_str),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('k',
+ "value",
+ "VALUE",
+ gettext_noop ("preference value"),
+ &opt_pref_value),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('V',
+ "verbose",
+ gettext_noop ("verbose output (include ATS address properties)"),
+ &opt_verbose),
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'d', "description", "FILE",
- gettext_noop ("description of the item to be sold"),
- 1, &GNUNET_GETOPT_set_filename, &fndesc},
- {'p', "pricemap", "FILE",
- gettext_noop ("mapping of possible prices"),
- 1, &GNUNET_GETOPT_set_filename, &fnprices},
- {'r', "roundtime", "DURATION",
- gettext_noop ("max duration per round"),
- 1, &GNUNET_GETOPT_set_relative_time, &dround},
- {'s', "regtime", "DURATION",
- gettext_noop ("duration until auction starts"),
- 1, &GNUNET_GETOPT_set_relative_time, &dstart},
- {'m', "m", "NUMBER",
- gettext_noop ("number of items to sell\n"
- "0 for first price auction\n"
- ">0 for vickrey/M+1st price auction"),
- 1, &GNUNET_GETOPT_set_uint, &m},
- {'u', "public", NULL,
- gettext_noop ("public auction outcome"),
- 0, &GNUNET_GETOPT_set_one, &outcome},
- {'i', "interactive", NULL,
- gettext_noop ("keep running in foreground until auction completes"),
- 0, &GNUNET_GETOPT_set_one, &interactive},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_FILENAME ('d',
+ "description",
+ "FILE",
+ gettext_noop ("description of the item to be sold"),
+ &fndesc),
+
+ GNUNET_GETOPT_OPTION_FILENAME ('p',
+ "pricemap",
+ "FILE",
+ gettext_noop ("mapping of possible prices"),
+ &fnprices),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('r',
+ "roundtime",
+ "DURATION",
+ gettext_noop ("max duration per round"),
+ &dround),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('s',
+ "regtime",
+ "DURATION",
+ gettext_noop ("duration until auction starts"),
+ &dstart),
+ GNUNET_GETOPT_OPTION_SET_UINT ('m',
+ "m",
+ "NUMBER",
+ gettext_noop ("number of items to sell\n"
+ "0 for first price auction\n"
+ ">0 for vickrey/M+1st price auction"),
+ &m),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "public",
+ gettext_noop ("public auction outcome"),
+ &outcome),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "interactive",
+ gettext_noop ("keep running in foreground until auction completes"),
+ &interactive),
+
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
{
int res;
const char helpstr[] = "Create tunnels and retrieve info about CADET's status.";
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
/* I would use the terminology 'circuit' here... --lynX */
- {'C', "connection", "CONNECTION_ID",
- gettext_noop ("Provide information about a particular connection"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
- {'e', "echo", NULL,
- gettext_noop ("Activate echo mode"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
- {'d', "dump", NULL,
- gettext_noop ("Dump debug information to STDERR"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &dump},
- {'o', "open-port", "SHARED_SECRET",
- gettext_noop ("Listen for connections using a shared secret among sender and recipient"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &listen_port},
- {'p', "peer", "PEER_ID",
- gettext_noop ("Provide information about a patricular peer"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &peer_id},
- {'P', "peers", NULL,
- gettext_noop ("Provide information about all peers"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &request_peers},
- {'t', "tunnel", "TUNNEL_ID",
- gettext_noop ("Provide information about a particular tunnel"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
- {'T', "tunnels", NULL,
- gettext_noop ("Provide information about all tunnels"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &request_tunnels},
+ GNUNET_GETOPT_OPTION_STRING ('C',
+ "connection",
+ "CONNECTION_ID",
+ gettext_noop ("Provide information about a particular connection"),
+ &conn_id),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "echo",
+ gettext_noop ("Activate echo mode"),
+ &echo),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "dump",
+ gettext_noop ("Dump debug information to STDERR"),
+ &dump),
+
+ GNUNET_GETOPT_OPTION_STRING ('o',
+ "open-port",
+ "SHARED_SECRET",
+ gettext_noop ("Listen for connections using a shared secret among sender and recipient"),
+ &listen_port),
+
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peer",
+ "PEER_ID",
+ gettext_noop ("Provide information about a patricular peer"),
+ &peer_id),
+
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('P',
+ "peers",
+ gettext_noop ("Provide information about all peers"),
+ &request_peers),
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "tunnel",
+ "TUNNEL_ID",
+ gettext_noop ("Provide information about a particular tunnel"),
+ &tunnel_id),
+
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('T',
+ "tunnels",
+ gettext_noop ("Provide information about all tunnels"),
+ &request_tunnels),
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char **argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'n', "num-peers", NULL,
- gettext_noop ("number of peers in consensus"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers },
- { 'k', "value-replication", NULL,
- gettext_noop ("how many peers (random selection without replacement) receive one value?"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &replication },
- { 'x', "num-values", NULL,
- gettext_noop ("number of values"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_values },
- { 't', "timeout", NULL,
- gettext_noop ("consensus timeout"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &conclude_timeout },
- { 'd', "delay", NULL,
- gettext_noop ("delay until consensus starts"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay },
- { 's', "statistics", NULL,
- gettext_noop ("write statistics to file"),
- GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },
- { 'S', "dist-static", NULL,
- gettext_noop ("distribute elements to a static subset of good peers"),
- GNUNET_YES, &GNUNET_GETOPT_set_one, &dist_static },
- { 'V', "verbose", NULL,
- gettext_noop ("be more verbose (print received values)"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "num-peers",
+ NULL,
+ gettext_noop ("number of peers in consensus"),
+ &num_peers),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('k',
+ "value-replication",
+ NULL,
+ gettext_noop ("how many peers (random selection without replacement) receive one value?"),
+ &replication),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('x',
+ "num-values",
+ NULL,
+ gettext_noop ("number of values"),
+ &num_values),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ NULL,
+ gettext_noop ("consensus timeout"),
+ &conclude_timeout),
+
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('d',
+ "delay",
+ NULL,
+ gettext_noop ("delay until consensus starts"),
+ &consensus_delay),
+
+ GNUNET_GETOPT_OPTION_FILENAME ('s',
+ "statistics",
+ "FILENAME",
+ gettext_noop ("write statistics to file"),
+ &statistics_filename),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('S',
+ "dist-static",
+ gettext_noop ("distribute elements to a static subset of good peers"),
+ &dist_static),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('V',
+ "verbose",
+ gettext_noop ("be more verbose (print received values)"),
+ &verbose),
+
GNUNET_GETOPT_OPTION_END
};
conclude_timeout = GNUNET_TIME_UNIT_SECONDS;
char *const *argv)
{
int res;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'m', "monitor", NULL,
- gettext_noop ("provide information about all current connections (continuously)"),
- 0, &GNUNET_GETOPT_set_one, &monitor_connections},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("provide information about all current connections (continuously)"),
+ &monitor_connections),
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 's', "sourcecfg", "FILENAME",
- gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"),
- 1, &GNUNET_GETOPT_set_filename, &alternative_cfg },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_FILENAME ('s',
+ "sourcecfg",
+ "FILENAME",
+ gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"),
+ &alternative_cfg),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
/**
* Be verbose
*/
-static int verbose;
+static unsigned int verbose;
/**
* Use DHT demultixplex_everywhere
}
-
-/**
- * gnunet-dht-get command line options
- */
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'k', "key", "KEY",
- gettext_noop ("the query key"),
- 1, &GNUNET_GETOPT_set_string, &query_key},
- {'r', "replication", "LEVEL",
- gettext_noop ("how many parallel requests (replicas) to create"),
- 1, &GNUNET_GETOPT_set_uint, &replication},
- {'t', "type", "TYPE",
- gettext_noop ("the type of data to look for"),
- 1, &GNUNET_GETOPT_set_uint, &query_type},
- {'T', "timeout", "TIMEOUT",
- gettext_noop ("how long to execute this query before giving up?"),
- 1, &GNUNET_GETOPT_set_relative_time, &timeout_request},
- {'x', "demultiplex", NULL,
- gettext_noop ("use DHT's demultiplex everywhere option"),
- 0, &GNUNET_GETOPT_set_one, &demultixplex_everywhere},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
- GNUNET_GETOPT_OPTION_END
-};
-
-
/**
* Entry point for gnunet-dht-get
*
int
main (int argc, char *const *argv)
{
+
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "KEY",
+ gettext_noop ("the query key"),
+ &query_key),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "replication",
+ "LEVEL",
+ gettext_noop ("how many parallel requests (replicas) to create"),
+ &replication),
+
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("the type of data to look for"),
+ &query_type),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T',
+ "timeout",
+ "TIMEOUT",
+ gettext_noop ("how long to execute this query before giving up?"),
+ &timeout_request),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('x',
+ "demultiplex",
+ gettext_noop ("use DHT's demultiplex everywhere option"),
+ &demultixplex_everywhere),
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+ GNUNET_GETOPT_OPTION_END
+ };
+
+
+
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
return (GNUNET_OK ==
NULL);
}
-
-/**
- * gnunet-dht-monitor command line options
- */
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'k', "key", "KEY",
- gettext_noop ("the query key"),
- 1, &GNUNET_GETOPT_set_string, &query_key},
- {'t', "type", "TYPE",
- gettext_noop ("the type of data to look for"),
- 1, &GNUNET_GETOPT_set_uint, &block_type},
- {'T', "timeout", "TIMEOUT",
- gettext_noop ("how long should the monitor command run"),
- 1, &GNUNET_GETOPT_set_relative_time, &timeout_request},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
- GNUNET_GETOPT_OPTION_END
-};
-
-
/**
* Entry point for gnunet-dht-monitor
*
int
main (int argc, char *const *argv)
{
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "KEY",
+ gettext_noop ("the query key"),
+ &query_key),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("the type of data to look for"),
+ &block_type),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T',
+ "timeout",
+ "TIMEOUT",
+ gettext_noop ("how long should the monitor command run"),
+ &timeout_request),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('V',
+ "verbose",
+ gettext_noop ("be verbose (print progress information)"),
+ &verbose),
+
+ GNUNET_GETOPT_OPTION_END
+ };
+
+
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
/**
* Be verbose
*/
-static int verbose;
+static unsigned int verbose;
/**
* Use #GNUNET_DHT_DEMULTIPLEX_EVERYWHERE.
NULL);
}
-
-/**
- * gnunet-dht-put command line options
- */
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'d', "data", "DATA",
- gettext_noop ("the data to insert under the key"),
- 1, &GNUNET_GETOPT_set_string, &data},
- {'e', "expiration", "EXPIRATION",
- gettext_noop ("how long to store this entry in the dht (in seconds)"),
- 1, &GNUNET_GETOPT_set_relative_time, &expiration},
- {'k', "key", "KEY",
- gettext_noop ("the query key"),
- 1, &GNUNET_GETOPT_set_string, &query_key},
- {'x', "demultiplex", NULL,
- gettext_noop ("use DHT's demultiplex everywhere option"),
- 0, &GNUNET_GETOPT_set_one, &demultixplex_everywhere},
- {'r', "replication", "LEVEL",
- gettext_noop ("how many replicas to create"),
- 1, &GNUNET_GETOPT_set_uint, &replication},
- {'R', "record", NULL,
- gettext_noop ("use DHT's record route option"),
- 0, &GNUNET_GETOPT_set_one, &record_route},
- {'t', "type", "TYPE",
- gettext_noop ("the type to insert data as"),
- 1, &GNUNET_GETOPT_set_uint, &query_type},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
- GNUNET_GETOPT_OPTION_END
-};
-
-
/**
* Entry point for gnunet-dht-put
*
int
main (int argc, char *const *argv)
{
+
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('d',
+ "data",
+ "DATA",
+ gettext_noop ("the data to insert under the key"),
+ &data),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('e',
+ "expiration",
+ "EXPIRATION",
+ gettext_noop ("how long to store this entry in the dht (in seconds)"),
+ &expiration),
+
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "KEY",
+ gettext_noop ("the query key"),
+ &query_key),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('x',
+ "demultiplex",
+ gettext_noop ("use DHT's demultiplex everywhere option"),
+ &demultixplex_everywhere),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "replication",
+ "LEVEL",
+ gettext_noop ("how many replicas to create"),
+ &replication),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('R',
+ "record",
+ gettext_noop ("use DHT's record route option"),
+ &record_route),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("the type to insert data as"),
+ &query_type),
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
+ GNUNET_GETOPT_OPTION_END
+ };
+
+
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 2;
{
int rc;
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'n', "peers", "COUNT",
- gettext_noop ("number of peers to start"),
- 1, &GNUNET_GETOPT_set_uint, &num_peers},
- {'s', "searches", "COUNT",
- gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"),
- 1, &GNUNET_GETOPT_set_uint, &max_searches},
- {'H', "hosts", "FILENAME",
- gettext_noop ("name of the file with the login information for the testbed"),
- 1, &GNUNET_GETOPT_set_string, &hosts_file},
- {'D', "delay", "DELAY",
- gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"),
- 1, &GNUNET_GETOPT_set_relative_time, &delay_stats},
- {'P', "PUT-delay", "DELAY",
- gettext_noop ("delay to start doing PUTs (default: 1 sec)"),
- 1, &GNUNET_GETOPT_set_relative_time, &delay_put},
- {'G', "GET-delay", "DELAY",
- gettext_noop ("delay to start doing GETs (default: 5 min)"),
- 1, &GNUNET_GETOPT_set_relative_time, &delay_get},
- {'r', "replication", "DEGREE",
- gettext_noop ("replication degree for DHT PUTs"),
- 1, &GNUNET_GETOPT_set_uint, &replication},
- {'t', "timeout", "TIMEOUT",
- gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"),
- 1, &GNUNET_GETOPT_set_relative_time, &timeout},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "peers",
+ "COUNT",
+ gettext_noop ("number of peers to start"),
+ &num_peers),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('s',
+ "searches",
+ "COUNT",
+ gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"),
+ &max_searches),
+
+ GNUNET_GETOPT_OPTION_STRING ('H',
+ "hosts",
+ "FILENAME",
+ gettext_noop ("name of the file with the login information for the testbed"),
+ &hosts_file),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('D',
+ "delay",
+ "DELAY",
+ gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"),
+ &delay_stats),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('P',
+ "PUT-delay",
+ "DELAY",
+ gettext_noop ("delay to start doing PUTs (default: 1 sec)"),
+ &delay_put),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('G',
+ "GET-delay",
+ "DELAY",
+ gettext_noop ("delay to start doing GETs (default: 5 min)"),
+ &delay_get),
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "replication",
+ "DEGREE",
+ gettext_noop ("replication degree for DHT PUTs"),
+ &replication),
+
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ "TIMEOUT",
+ gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"),
+ &timeout),
GNUNET_GETOPT_OPTION_END
};
/**
* Selected level of verbosity.
*/
-static int verbosity;
+static unsigned int verbosity;
/**
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'i', "inbound-only", NULL,
- gettext_noop ("only monitor DNS queries"),
- 0, &GNUNET_GETOPT_set_one, &inbound_only},
- {'o', "outbound-only", NULL,
- gettext_noop ("only monitor DNS replies"),
- 0, &GNUNET_GETOPT_set_one, &outbound_only},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "inbound-only",
+ gettext_noop ("only monitor DNS queries"),
+ &inbound_only),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('o',
+ "outbound-only",
+ gettext_noop ("only monitor DNS queries"),
+ &outbound_only),
+
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
/**
* Selected level of verbosity.
*/
-static int verbosity;
+static unsigned int verbosity;
/**
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'4', "ipv4", "IPV4",
- gettext_noop ("set A records"),
- 1, &GNUNET_GETOPT_set_string, &n4},
- {'6', "ipv4", "IPV6",
- gettext_noop ("set AAAA records"),
- 1, &GNUNET_GETOPT_set_string, &n6},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_STRING ('4',
+ "ipv4",
+ "IPV4",
+ gettext_noop ("set A records"),
+ &n4),
+
+ GNUNET_GETOPT_OPTION_STRING ('6',
+ "ipv4",
+ "IPV6",
+ gettext_noop ("set AAAA records"),
+ &n6),
+
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
*/
#include "platform.h"
#include "gnunet_fs_service.h"
+#include "gnunet_getopt_lib.h"
#include "fs_api.h"
/* ******************** command-line option parsing API ******************** */
* @param value command line argument given
* @return GNUNET_OK on success
*/
-int
-GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
- *ctx, void *scls, const char *option,
- const char *value)
+static int
+getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
+ *ctx, void *scls, const char *option,
+ const char *value)
{
struct GNUNET_FS_Uri **uri = scls;
struct GNUNET_FS_Uri *u = *uri;
return GNUNET_OK;
}
+/**
+ * Allow user to specify keywords.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] topKeywords set to the desired value
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_FS_GETOPT_KEYWORDS (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_FS_Uri **topKeywords)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &getopt_set_keywords,
+ .scls = (void *) topKeywords
+ };
+
+ return clo;
+}
/**
* Command-line option parser function that allows the user to specify
* @param value command line argument given
* @return #GNUNET_OK on success
*/
-int
-GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value)
+static int
+getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
struct GNUNET_CONTAINER_MetaData **mm = scls;
#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
return GNUNET_OK;
}
+/**
+ * Allow user to specify metadata.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] metadata set to the desired value
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_FS_GETOPT_METADATA (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_CONTAINER_MetaData **meta)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &getopt_set_metadata,
+ .scls = (void *) meta
+ };
+
+ return clo;
+}
+
+
+
+
/* end of fs_getopt.c */
/**
* Are we running 'verbosely'?
*/
-static int verbose;
+static unsigned int verbose;
/**
* Configuration to use.
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "anonymity", "LEVEL",
- gettext_noop ("set the desired LEVEL of sender-anonymity"),
- 1, &GNUNET_GETOPT_set_uint, &anonymity_level},
- {'d', "disable-creation-time", NULL,
- gettext_noop
- ("disable adding the creation time to the metadata of the uploaded file"),
- 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
- {'D', "disable-extractor", NULL,
- gettext_noop ("do not use libextractor to add keywords or metadata"),
- 0, &GNUNET_GETOPT_set_one, &disable_extractor},
- {'p', "priority", "PRIORITY",
- gettext_noop ("specify the priority of the content"),
- 1, &GNUNET_GETOPT_set_uint, &content_priority},
- {'r', "replication", "LEVEL",
- gettext_noop ("set the desired replication LEVEL"),
- 1, &GNUNET_GETOPT_set_uint, &replication_level},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('a',
+ "anonymity",
+ "LEVEL",
+ gettext_noop ("set the desired LEVEL of sender-anonymity"),
+ &anonymity_level),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "disable-creation-time",
+ gettext_noop ("disable adding the creation time to the metadata of the uploaded file"),
+ &do_disable_creation_time),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "disable-extractor",
+ gettext_noop ("do not use libextractor to add keywords or metadata"),
+ &disable_extractor),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "priority",
+ "PRIORITY",
+ gettext_noop ("specify the priority of the content"),
+ &content_priority),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "replication",
+ "LEVEL",
+ gettext_noop ("set the desired replication LEVEL"),
+ &replication_level),
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
GNUNET_GETOPT_OPTION_END
};
struct WorkItem *wi;
static int ret;
-static int verbose;
+static unsigned int verbose;
static int delete_incomplete;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "anonymity", "LEVEL",
- gettext_noop ("set the desired LEVEL of receiver-anonymity"),
- 1, &GNUNET_GETOPT_set_uint, &anonymity},
- {'D', "delete-incomplete", NULL,
- gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
- 0, &GNUNET_GETOPT_set_one, &delete_incomplete},
- {'n', "no-network", NULL,
- gettext_noop ("only search the local peer (no P2P network search)"),
- 0, &GNUNET_GETOPT_set_one, &local_only},
- {'o', "output", "FILENAME",
- gettext_noop ("write the file to FILENAME"),
- 1, &GNUNET_GETOPT_set_string, &filename},
- {'p', "parallelism", "DOWNLOADS",
- gettext_noop
- ("set the maximum number of parallel downloads that is allowed"),
- 1, &GNUNET_GETOPT_set_uint, ¶llelism},
- {'r', "request-parallelism", "REQUESTS",
- gettext_noop
- ("set the maximum number of parallel requests for blocks that is allowed"),
- 1, &GNUNET_GETOPT_set_uint, &request_parallelism},
- {'R', "recursive", NULL,
- gettext_noop ("download a GNUnet directory recursively"),
- 0, &GNUNET_GETOPT_set_one, &do_recursive},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_increment_value, &verbose},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_UINT ('a',
+ "anonymity",
+ "LEVEL",
+ gettext_noop ("set the desired LEVEL of receiver-anonymity"),
+ &anonymity),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "delete-incomplete",
+ gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
+ &delete_incomplete),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "no-network",
+ gettext_noop ("only search the local peer (no P2P network search)"),
+ &local_only),
+
+ GNUNET_GETOPT_OPTION_STRING ('o',
+ "output",
+ "FILENAME",
+ gettext_noop ("write the file to FILENAME"),
+ &filename),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "parallelism",
+ "DOWNLOADS",
+ gettext_noop ("set the maximum number of parallel downloads that is allowed"),
+ ¶llelism),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "request-parallelism",
+ "REQUESTS",
+ gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"),
+ &request_parallelism),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('R',
+ "recursive",
+ gettext_noop ("download a GNUnet directory recursively"),
+ &do_recursive),
+
+ GNUNET_GETOPT_OPTION_INCREMENT_VALUE ('V',
+ "verbose",
+ gettext_noop ("be verbose (print progress information)"),
+ &verbose),
+
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'n', "num-peers", "COUNT",
- gettext_noop ("run the experiment with COUNT peers"),
- 1, &GNUNET_GETOPT_set_uint, &num_peers},
- {'H', "hosts", "HOSTFILE",
- gettext_noop ("specifies name of a file with the HOSTS the testbed should use"),
- 1, &GNUNET_GETOPT_set_string, &host_filename},
- {'t', "timeout", "DELAY",
- gettext_noop ("automatically terminate experiment after DELAY"),
- 1, &GNUNET_GETOPT_set_relative_time, &timeout},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "num-peers",
+ "COUNT",
+ gettext_noop ("run the experiment with COUNT peers"),
+ &num_peers),
+
+ GNUNET_GETOPT_OPTION_STRING ('H',
+ "hosts",
+ "HOSTFILE",
+ gettext_noop ("specifies name of a file with the HOSTS the testbed should use"),
+ &host_filename),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ "DELAY",
+ gettext_noop ("automatically terminate experiment after DELAY"),
+ &timeout),
+
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
/**
* Option -v given?
*/
-static int verbose;
+static unsigned int verbose;
/**
int
main (int argc, char *const *argv)
{
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'i', "list-indexed", NULL,
- gettext_noop ("print a list of all indexed files"), 0,
- &GNUNET_GETOPT_set_one, &list_indexed_files},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "list-indexed",
+ gettext_noop ("print a list of all indexed files"),
+ &list_indexed_files),
+
GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
GNUNET_GETOPT_OPTION_END
};
/**
* Command line option 'verbose' set
*/
-static int verbose;
+static unsigned int verbose;
/**
* Handle to our configuration.
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "anonymity", "LEVEL",
- gettext_noop ("set the desired LEVEL of sender-anonymity"),
- 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level},
- {'d', "disable-creation-time", NULL,
- gettext_noop
- ("disable adding the creation time to the metadata of the uploaded file"),
- 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
- {'D', "disable-extractor", NULL,
- gettext_noop ("do not use libextractor to add keywords or metadata"),
- 0, &GNUNET_GETOPT_set_one, &disable_extractor},
- {'e', "extract", NULL,
- gettext_noop
- ("print list of extracted keywords that would be used, but do not perform upload"),
- 0, &GNUNET_GETOPT_set_one, &extract_only},
- {'k', "key", "KEYWORD",
- gettext_noop
- ("add an additional keyword for the top-level file or directory"
- " (this option can be specified multiple times)"),
- 1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
- {'m', "meta", "TYPE:VALUE",
- gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
- 1, &GNUNET_FS_getopt_set_metadata, &meta},
- {'n', "noindex", NULL,
- gettext_noop ("do not index, perform full insertion (stores entire "
- "file in encrypted form in GNUnet database)"),
- 0, &GNUNET_GETOPT_set_one, &do_insert},
- {'N', "next", "ID",
- gettext_noop
- ("specify ID of an updated version to be published in the future"
- " (for namespace insertions only)"),
- 1, &GNUNET_GETOPT_set_string, &next_id},
- {'p', "priority", "PRIORITY",
- gettext_noop ("specify the priority of the content"),
- 1, &GNUNET_GETOPT_set_uint, &bo.content_priority},
- {'P', "pseudonym", "NAME",
- gettext_noop
- ("publish the files under the pseudonym NAME (place file into namespace)"),
- 1, &GNUNET_GETOPT_set_string, &pseudonym},
- {'r', "replication", "LEVEL",
- gettext_noop ("set the desired replication LEVEL"),
- 1, &GNUNET_GETOPT_set_uint, &bo.replication_level},
- {'s', "simulate-only", NULL,
- gettext_noop ("only simulate the process but do not do any "
- "actual publishing (useful to compute URIs)"),
- 0, &GNUNET_GETOPT_set_one, &do_simulate},
- {'t', "this", "ID",
- gettext_noop ("set the ID of this version of the publication"
- " (for namespace insertions only)"),
- 1, &GNUNET_GETOPT_set_string, &this_id},
- {'u', "uri", "URI",
- gettext_noop ("URI to be published (can be used instead of passing a "
- "file to add keywords to the file with the respective URI)"),
- 1, &GNUNET_GETOPT_set_string, &uri_string},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_UINT ('a',
+ "anonymity",
+ "LEVEL",
+ gettext_noop ("set the desired LEVEL of sender-anonymity"),
+ &bo.anonymity_level),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "disable-creation-time",
+ gettext_noop ("disable adding the creation time to the "
+ "metadata of the uploaded file"),
+ &do_disable_creation_time),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "disable-extractor",
+ gettext_noop ("do not use libextractor to add keywords or metadata"),
+ &disable_extractor),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "extract",
+ gettext_noop ("print list of extracted keywords that would "
+ "be used, but do not perform upload"),
+ &extract_only),
+
+ GNUNET_FS_GETOPT_KEYWORDS ('k',
+ "key",
+ "KEYWORD",
+ gettext_noop ("add an additional keyword for the top-level "
+ "file or directory (this option can be specified multiple times)"),
+ &topKeywords),
+
+ GNUNET_FS_GETOPT_METADATA ('m',
+ "meta",
+ "TYPE:VALUE",
+ gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
+ &meta),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "noindex",
+ gettext_noop ("do not index, perform full insertion (stores "
+ "entire file in encrypted form in GNUnet database)"),
+ &do_insert),
+
+ GNUNET_GETOPT_OPTION_STRING ('N',
+ "next",
+ "ID",
+ gettext_noop ("specify ID of an updated version to be "
+ "published in the future (for namespace insertions only)"),
+ &next_id),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "priority",
+ "PRIORITY",
+ gettext_noop ("specify the priority of the content"),
+ &bo.content_priority),
+
+ GNUNET_GETOPT_OPTION_STRING ('P',
+ "pseudonym",
+ "NAME",
+ gettext_noop ("publish the files under the pseudonym "
+ "NAME (place file into namespace)"),
+ &pseudonym),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('r',
+ "replication",
+ "LEVEL",
+ gettext_noop ("set the desired replication LEVEL"),
+ &bo.replication_level),
+
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "simulate-only",
+ gettext_noop ("only simulate the process but do not do "
+ "any actual publishing (useful to compute URIs)"),
+ &do_simulate),
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "this",
+ "ID",
+ gettext_noop ("set the ID of this version of the publication "
+ "(for namespace insertions only)"),
+ &this_id),
+
+ GNUNET_GETOPT_OPTION_STRING ('u',
+ "uri",
+ "URI",
+ gettext_noop ("URI to be published (can be used instead of passing a "
+ "file to add keywords to the file with the respective URI)"),
+ &uri_string),
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
GNUNET_GETOPT_OPTION_END
};
bo.expiration_time =
static unsigned int results;
-static int verbose;
+static unsigned int verbose;
static int local_only;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "anonymity", "LEVEL",
- gettext_noop ("set the desired LEVEL of receiver-anonymity"),
- 1, &GNUNET_GETOPT_set_uint, &anonymity},
- {'n', "no-network", NULL,
- gettext_noop ("only search the local peer (no P2P network search)"),
- 0, &GNUNET_GETOPT_set_one, &local_only},
- {'o', "output", "PREFIX",
- gettext_noop ("write search results to file starting with PREFIX"),
- 1, &GNUNET_GETOPT_set_string, &output_filename},
- {'t', "timeout", "DELAY",
- gettext_noop ("automatically terminate search after DELAY"),
- 1, &GNUNET_GETOPT_set_relative_time, &timeout},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
- {'N', "results", "VALUE",
- gettext_noop
- ("automatically terminate search after VALUE results are found"),
- 1, &GNUNET_GETOPT_set_uint, &results_limit},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('a',
+ "anonymity",
+ "LEVEL",
+ gettext_noop ("set the desired LEVEL of receiver-anonymity"),
+ &anonymity),
+
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "no-network",
+ gettext_noop ("only search the local peer (no P2P network search)"),
+ &local_only),
+
+ GNUNET_GETOPT_OPTION_STRING ('o',
+ "output",
+ "PREFIX",
+ gettext_noop ("write search results to file starting with PREFIX"),
+ &output_filename),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ "DELAY",
+ gettext_noop ("automatically terminate search after DELAY"),
+ &timeout),
+
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('N',
+ "results",
+ "VALUE",
+ gettext_noop ("automatically terminate search "
+ "after VALUE results are found"),
+ &results_limit),
+
GNUNET_GETOPT_OPTION_END
};
static int ret;
-static int verbose;
+static unsigned int verbose;
static const struct GNUNET_CONFIGURATION_Handle *cfg;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_set_one, &verbose},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'p', "port", "PORT",
- gettext_noop ("Run HTTP serve on port PORT (default is 8888)"), 1,
- &GNUNET_GETOPT_set_uint, &port},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "port",
+ "PORT",
+ gettext_noop ("Run HTTP serve on port PORT (default is 8888)"),
+ &port),
+
GNUNET_GETOPT_OPTION_END
};
int ret;
main (int argc,
char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'d', "dns", "IP",
- gettext_noop ("IP of recursive DNS resolver to use (required)"), 1,
- &GNUNET_GETOPT_set_string, &dns_ip},
- {'f', "fcfs", "NAME",
- gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"), 1,
- &GNUNET_GETOPT_set_string, &fcfs_suffix},
- {'s', "suffix", "SUFFIX",
- gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), 1,
- &GNUNET_GETOPT_set_string, &dns_suffix},
- {'p', "port", "UDPPORT",
- gettext_noop ("UDP port to listen on for inbound DNS requests; default: 2853"), 1,
- &GNUNET_GETOPT_set_uint, &listen_port},
- {'z', "zone", "PUBLICKEY",
- gettext_noop ("Public key of the GNS zone to use (overrides default)"), 1,
- &GNUNET_GETOPT_set_string, &gns_zone_str},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('d',
+ "dns",
+ "IP",
+ gettext_noop ("IP of recursive DNS resolver to use (required)"),
+ &dns_ip),
+
+ GNUNET_GETOPT_OPTION_STRING ('f',
+ "fcfs",
+ "NAME",
+ gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"),
+ &fcfs_suffix),
+
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "suffix",
+ "SUFFIX",
+ gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"),
+ &dns_suffix),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "port",
+ "UDPPORT",
+ gettext_noop ("UDP port to listen on for inbound DNS requests; default: 2853"),
+ &listen_port),
+
+ GNUNET_GETOPT_OPTION_STRING ('z',
+ "zone",
+ "PUBLICKEY",
+ gettext_noop ("Public key of the GNS zone to use (overrides default)"),
+ &gns_zone_str),
+
GNUNET_GETOPT_OPTION_END
};
int ret;
/**
* The port the proxy is running on (default 7777)
*/
-static unsigned long port = GNUNET_GNS_PROXY_PORT;
+static unsigned long long port = GNUNET_GNS_PROXY_PORT;
/**
* The CA file (pem) to use for the proxy CA
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Proxy listens on port %lu\n",
+ "Proxy listens on port %llu\n",
port);
/* start MHD daemon for HTTP */
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'p', "port", NULL,
- gettext_noop ("listen on specified port (default: 7777)"), 1,
- &GNUNET_GETOPT_set_ulong, &port},
- {'a', "authority", NULL,
- gettext_noop ("pem file to use as CA"), 1,
- &GNUNET_GETOPT_set_string, &cafile_opt},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ULONG ('p',
+ "port",
+ NULL,
+ gettext_noop ("listen on specified port (default: 7777)"),
+ &port),
+
+ GNUNET_GETOPT_OPTION_STRING ('a',
+ "authority",
+ NULL,
+ gettext_noop ("pem file to use as CA"),
+ &cafile_opt),
+
GNUNET_GETOPT_OPTION_END
};
static const char* page =
main (int argc,
char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'u', "lookup", "NAME",
- gettext_noop ("Lookup a record for the given name"), 1,
- &GNUNET_GETOPT_set_string, &lookup_name},
- {'t', "type", "TYPE",
- gettext_noop ("Specify the type of the record to lookup"), 1,
- &GNUNET_GETOPT_set_string, &lookup_type},
- { 'T', "timeout", "DELAY",
- gettext_noop ("Specify timeout for the lookup"), 1,
- &GNUNET_GETOPT_set_relative_time, &timeout },
- {'r', "raw", NULL,
- gettext_noop ("No unneeded output"), 0,
- &GNUNET_GETOPT_set_one, &raw},
- {'p', "public-key", "PKEY",
- gettext_noop ("Specify the public key of the zone to lookup the record in"), 1,
- &GNUNET_GETOPT_set_string, &public_key},
- {'z', "zone", "NAME",
- gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1,
- &GNUNET_GETOPT_set_string, &zone_ego_name},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('u',
+ "lookup",
+ "NAME",
+ gettext_noop ("Lookup a record for the given name"),
+ &lookup_name),
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("Specify the type of the record to lookup"),
+ &lookup_type),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T',
+ "timeout",
+ "DELAY",
+ gettext_noop ("Specify timeout for the lookup"),
+ &timeout),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('r',
+ "raw",
+ gettext_noop ("No unneeded output"),
+ &raw),
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "public-key",
+ "PKEY",
+ gettext_noop ("Specify the public key of the zone to lookup the record in"),
+ &public_key),
+
+ GNUNET_GETOPT_OPTION_STRING ('z',
+ "zone",
+ "NAME",
+ gettext_noop ("Specify the name of the ego of the zone to lookup the record in"),
+ &zone_ego_name),
+
GNUNET_GETOPT_OPTION_END
};
int ret;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
#if HAVE_MHD
- {'a', "advertise", NULL,
- gettext_noop ("advertise our hostlist to other peers"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &advertising},
+ GNUNET_GETOPT_OPTION_SET_ONE ('a',
+ "advertise",
+ gettext_noop ("advertise our hostlist to other peers"),
+ &advertising),
#endif
- {'b', "bootstrap", NULL,
- gettext_noop
- ("bootstrap using hostlists (it is highly recommended that you always use this option)"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &bootstrapping},
- {'e', "enable-learning", NULL,
- gettext_noop ("enable learning about hostlist servers from other peers"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &learning},
+ GNUNET_GETOPT_OPTION_SET_ONE ('b',
+ "bootstrap",
+ gettext_noop ("bootstrap using hostlists (it is highly recommended that you always use this option)"),
+ &bootstrapping),
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "enable-learning",
+ gettext_noop ("enable learning about hostlist servers from other peers"),
+ &learning),
#if HAVE_MHD
- {'p', "provide-hostlist", NULL,
- gettext_noop ("provide a hostlist server"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &provide_hostlist},
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "provide-hostlist",
+ gettext_noop ("provide a hostlist server"),
+ &provide_hostlist),
#endif
GNUNET_GETOPT_OPTION_END
};
int
main(int argc, char *const argv[])
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'t', "token", NULL,
- gettext_noop ("GNUid token"), 1,
- &GNUNET_GETOPT_set_string, &token},
- {'p', "print", NULL,
- gettext_noop ("Print token contents"), 0,
- &GNUNET_GETOPT_set_one, &print_token},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "token",
+ NULL,
+ gettext_noop ("GNUid token"),
+ &token),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "print",
+ gettext_noop ("Print token contents"),
+ &print_token),
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'C', "create", "NAME",
- gettext_noop ("create ego NAME"),
- 1, &GNUNET_GETOPT_set_string, &create_ego},
- {'D', "delete", "NAME",
- gettext_noop ("delete ego NAME "),
- 1, &GNUNET_GETOPT_set_string, &delete_ego},
- {'d', "display", NULL,
- gettext_noop ("display all egos"),
- 0, &GNUNET_GETOPT_set_one, &list},
- {'e', "ego", "NAME",
- gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -s)"),
- 1, &GNUNET_GETOPT_set_string, &set_ego},
- {'m', "monitor", NULL,
- gettext_noop ("run in monitor mode egos"),
- 0, &GNUNET_GETOPT_set_one, &monitor},
- {'s', "set", "SUBSYSTEM",
- gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
- 1, &GNUNET_GETOPT_set_string, &set_subsystem},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_STRING ('C',
+ "create",
+ "NAME",
+ gettext_noop ("create ego NAME"),
+ &create_ego),
+
+ GNUNET_GETOPT_OPTION_STRING ('D',
+ "delete",
+ "NAME",
+ gettext_noop ("delete ego NAME "),
+ &delete_ego),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "display",
+ gettext_noop ("display all egos"),
+ &list),
+
+ GNUNET_GETOPT_OPTION_STRING ('e',
+ "ego",
+ "NAME",
+ gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -s)"),
+ &set_ego),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("run in monitor mode egos"),
+ &monitor),
+
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "set",
+ "SUBSYSTEM",
+ gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
+ &set_subsystem),
+
GNUNET_GETOPT_OPTION_END
};
int res;
/* ******************** command-line option parsing API *********************** */
/**
- * Command-line option parser function that allows the user
- * to specify one or more '-k' options with keywords. Each
- * specified keyword will be added to the URI. A pointer to
- * the URI must be passed as the "scls" argument.
- *
- * @param ctx command line processor context
- * @param scls must be of type "struct GNUNET_FS_Uri **"
- * @param option name of the option (typically 'k')
- * @param value command line argument given
- * @return #GNUNET_OK on success
- */
-int
-GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value);
-
+ * Allow user to specify keywords.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] topKeywords set to the desired value
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_FS_GETOPT_KEYWORDS (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_FS_Uri **topKeywords);
+
+/**
+ * Allow user to specify metadata.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] metadata set to the desired value
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_FS_GETOPT_METADATA (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_CONTAINER_MetaData **meta);
/**
* Command-line option parser function that allows the user to specify
const char *option,
const char *value);
+
/**
* @brief Definition of a command line option.
*/
*/
int require_argument;
+ /**
+ * Is the presence of this option mandatory?
+ */
+ int option_mandatory;
+
/**
* Handler for the option.
*/
GNUNET_GETOPT_CommandLineOptionProcessor processor;
+ /**
+ * Function to call on @e scls to clean up after processing all
+ * the arguments. Can be NULL.
+ */
+ void (*cleaner)(void *cls);
+
/**
* Specific closure to pass to the processor.
*/
};
+
/**
- * Macro defining the option to print the command line
+ * Defining the option to print the command line
* help text (-h option).
*
* @param about string with brief description of the application
*/
-#define GNUNET_GETOPT_OPTION_HELP(about) \
- { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, &GNUNET_GETOPT_format_help_, (void *) about }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_HELP (const char *about);
/**
- * Macro defining the option to print the version of
+ * Define the option to print the version of
* the application (-v option)
*
* @param version string with the version number
*/
-#define GNUNET_GETOPT_OPTION_VERSION(version) \
- { 'v', "version", (const char *) NULL, gettext_noop("print the version number"), 0, &GNUNET_GETOPT_print_version_, (void *) version }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_VERSION (const char *version);
+
/**
* Allow user to specify log file name (-l option)
*
- * @param logfn set to the name of the logfile
+ * @param[out] logfn set to the name of the logfile
*/
-#define GNUNET_GETOPT_OPTION_LOGFILE(logfn) \
- { 'l', "logfile", "LOGFILE", gettext_noop("configure logging to write logs to LOGFILE"), 1, &GNUNET_GETOPT_set_string, (void *) logfn }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
/**
- * Allow user to specify log level (-L option)
+ * Allow user to specify a string.
*
- * @param loglev set to the log level
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] str set to the string
*/
-#define GNUNET_GETOPT_OPTION_LOGLEVEL(loglev) \
- { 'L', "log", "LOGLEVEL", gettext_noop("configure logging to use LOGLEVEL"), 1, &GNUNET_GETOPT_set_string, (void *) loglev }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_STRING (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ char **str);
+
+/**
+ * Allow user to specify a filename (automatically path expanded).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] str set to the string
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_FILENAME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ char **str);
/**
- * Get number of verbose (-V) flags
+ * Allow user to specify a binary value using Crockford
+ * Base32 encoding.
*
- * @param level where to store the verbosity level (should be an 'int')
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val binary value decoded from Crockford Base32-encoded argument
+ * @param val_size size of @a val in bytes
*/
-#define GNUNET_GETOPT_OPTION_VERBOSE(level) \
- { 'V', "verbose", (const char *) NULL, gettext_noop("be verbose"), 0, &GNUNET_GETOPT_increment_value, (void *) level }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ void *val,
+ size_t val_size);
/**
- * Get configuration file name (-c option)
+ * Allow user to specify a binary value using Crockford
+ * Base32 encoding where the size of the binary value is
+ * automatically determined from its type.
*
- * @param fn set to the configuration file name
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val binary value decoded from Crockford Base32-encoded argument;
+ * size is determined by type (sizeof (*val)).
*/
-#define GNUNET_GETOPT_OPTION_CFG_FILE(fn) \
- { 'c', "config", "FILENAME", gettext_noop("use configuration file FILENAME"), 1, &GNUNET_GETOPT_set_string, (void *) fn }
+#define GNUNET_GETOPT_OPTION_SET_BASE32_AUTO(shortName,name,argumentHelp,description,val) \
+ GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE(shortName,name,argumentHelp,description,val,sizeof(*val))
/**
- * Marker for the end of the list of options.
+ * Allow user to specify a flag (which internally means setting
+ * an integer to 1/#GNUNET_YES/#GNUNET_OK.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param description long help text for the option
+ * @param[out] val set to 1 if the option is present
*/
-#define GNUNET_GETOPT_OPTION_END \
- { '\0', NULL, NULL, NULL, 0, NULL, NULL }
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
+ const char *name,
+ const char *description,
+ int *val);
/**
- * Parse the command line.
+ * Allow user to specify an `unsigned int`.
*
- * @param binaryOptions Name of application with option summary
- * @param allOptions defined options and handlers
- * @param argc number of arguments in @a argv
- * @param argv actual arguments
- * @return index into argv with first non-option
- * argument, or #GNUNET_SYSERR on error
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the value specified at the command line
*/
-int
-GNUNET_GETOPT_run (const char *binaryOptions,
- const struct GNUNET_GETOPT_CommandLineOption *allOptions,
- unsigned int argc, char *const *argv);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned int *val);
/**
- * Set an option of type 'unsigned long long' from the command line.
- * A pointer to this function should be passed as part of the
- * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type `unsigned long long`.
+ * Allow user to specify an `unsigned long long`.
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the 'unsigned long long')
- * @param option name of the option
- * @param value actual value of the option as a string.
- * @return #GNUNET_OK if parsing the value worked
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the value specified at the command line
*/
-int
-GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned long long *val);
/**
- * Set an option of type 'struct GNUNET_TIME_Relative' from the command line.
- * A pointer to this function should be passed as part of the
- * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type `struct GNUNET_TIME_Relative`.
+ * Allow user to specify a `struct GNUNET_TIME_Relative`
+ * (using human-readable "fancy" time).
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the 'struct GNUNET_TIME_Relative')
- * @param option name of the option
- * @param value actual value of the option as a string.
- * @return #GNUNET_OK if parsing the value worked
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
*/
-int
-GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Relative *val);
/**
- * Set an option of type 'unsigned int' from the command line.
- * A pointer to this function should be passed as part of the
- * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type `unsigned int`.
+ * Allow user to specify a `struct GNUNET_TIME_Absolute`
+ * (using human-readable "fancy" time).
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the 'unsigned int')
- * @param option name of the option
- * @param value actual value of the option as a string.
- * @return #GNUNET_OK if parsing the value worked
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
*/
-int
-GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Absolute *val);
/**
- * Set an option of type 'int' from the command line to 1 if the
- * given option is present.
- * A pointer to this function should be passed as part of the
- * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type `int`.
+ * Increment @a val each time the option flag is given by one.
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the `int`)
- * @param option name of the option
- * @param value not used (NULL)
- * @return #GNUNET_OK (always)
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to 1 if the option is present
*/
-int
-GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
+ const char *name,
+ const char *description,
+ unsigned int *val);
/**
- * Set an option of type 'char *' from the command line.
- * A pointer to this function should be passed as part of the
- * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type `char *`, which will be allocated with the requested string.
+ * Define the '-L' log level option. Note that we do not check
+ * that the log level is valid here.
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the `char *`,
- * which will be allocated)
- * @param option name of the option
- * @param value actual value of the option (a string)
- * @return #GNUNET_OK (always)
+ * @param[out] level set to the log level
*/
-int
-GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_LOGLEVEL (char **level);
/**
- * Set an option of type 'char *' from the command line doing fs expansion.
- * A pointer to this function should be passed as part of the
- * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type 'char *', which will be allocated with the requested string.
+ * Define the '-V' verbosity option. Using the option more
+ * than once increments @a level each time.
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the 'char *',
- * which will be allocated)
- * @param option name of the option
- * @param value actual value of the option (a string)
- * @return #GNUNET_OK (always)
+ * @param[out] level set to the verbosity level
*/
-int
-GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level);
+
/**
- * Set an option of type 'unsigned int' from the command line. Each
- * time the option flag is given, the value is incremented by one.
- * A pointer to this function should be passed as part of the
- * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
- * of this type. It should be followed by a pointer to a value of
- * type 'int'.
+ * Allow user to specify log file name (-l option)
*
- * @param ctx command line processing context
- * @param scls additional closure (will point to the 'int')
- * @param option name of the option
- * @param value not used (NULL)
- * @return #GNUNET_OK (always)
+ * @param[out] logfn set to the name of the logfile
*/
-int
-GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext
- *ctx, void *scls, const char *option,
- const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
-/* *************** internal prototypes - use macros above! ************* */
+/**
+ * Allow user to specify configuration file name (-c option)
+ *
+ * @param[out] fn set to the name of the configuration file
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_CFG_FILE (char **fn);
+
/**
- * Print out details on command line options (implements --help).
+ * Make the given option mandatory.
*
- * @param ctx command line processing context
- * @param scls additional closure (points to about text)
- * @param option name of the option
- * @param value not used (NULL)
- * @return #GNUNET_NO (do not continue, not an error)
+ * @param opt option to modify
+ * @return @a opt with the mandatory flag set.
*/
-int
-GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext
- *ctx, void *scls, const char *option,
- const char *value);
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_MANDATORY (struct GNUNET_GETOPT_CommandLineOption opt);
+
/**
- * Print out program version (implements --version).
+ * Marker for the end of the list of options.
+ */
+#define GNUNET_GETOPT_OPTION_END \
+ { '\0', NULL, NULL, NULL, 0, 0, NULL, NULL, NULL }
+
+
+/**
+ * Parse the command line.
*
- * @param ctx command line processing context
- * @param scls additional closure (points to version string)
- * @param option name of the option
- * @param value not used (NULL)
- * @return #GNUNET_NO (do not continue, not an error)
+ * @param binaryOptions Name of application with option summary
+ * @param allOptions defined options and handlers
+ * @param argc number of arguments in @a argv
+ * @param argv actual arguments
+ * @return index into argv with first non-option
+ * argument, or #GNUNET_SYSERR on error
*/
int
-GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext
- *ctx, void *scls, const char *option,
- const char *value);
+GNUNET_GETOPT_run (const char *binaryOptions,
+ const struct GNUNET_GETOPT_CommandLineOption *allOptions,
+ unsigned int argc,
+ char *const *argv);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
GNUNET_JSON_post_parser_cleanup (void *con_cls);
+/* ****************** GETOPT JSON helper ******************* */
+
+
+/**
+ * Allow user to specify a JSON input value.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the JSON specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_JSON_getopt (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ json_t **json);
+
+
#endif
/* end of gnunet_json_lib.h */
/*
This file is part of GNUnet
- Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+ Copyright (C) 2014-2017 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
void
GNUNET_JSON_parse_free (struct GNUNET_JSON_Specification *spec)
{
- unsigned int i;
-
- for (i=0;NULL != spec[i].parser;i++)
+ for (unsigned int i=0;NULL != spec[i].parser;i++)
if (NULL != spec[i].cleaner)
spec[i].cleaner (spec[i].cls,
&spec[i]);
}
+/**
+ * Set an option with a JSON value from the command line.
+ * A pointer to this function should be passed as part of the
+ * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
+ * of this type.
+ *
+ * @param ctx command line processing context
+ * @param scls additional closure (will point to the 'json_t *')
+ * @param option name of the option
+ * @param value actual value of the option as a string.
+ * @return #GNUNET_OK if parsing the value worked
+ */
+static int
+set_json (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
+{
+ json_t **json = scls;
+ json_error_t error;
+
+ *json = json_loads (value,
+ JSON_REJECT_DUPLICATES,
+ &error);
+ if (NULL == *json)
+ {
+ FPRINTF (stderr,
+ _("Failed to parse JSON in option `%s': %s (%s)\n"),
+ option,
+ error.text,
+ error.source);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Allow user to specify a JSON input value.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the JSON specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_JSON_getopt (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ json_t **json)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_json,
+ .scls = (void *) json
+ };
+
+ return clo;
+}
+
+
/* end of json.c */
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'n', "name", "NAME",
- gettext_noop ("name of the record to add/delete/display"), 1,
- &GNUNET_GETOPT_set_string, &name},
- {'z', "zone", "PKEY",
- gettext_noop ("spezifies the public key of the zone to look in"), 1,
- &GNUNET_GETOPT_set_string, &pkey},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_STRING ('n',
+ "name",
+ "NAME",
+ gettext_noop ("name of the record to add/delete/display"),
+ &name),
+
+ GNUNET_GETOPT_OPTION_STRING ('z',
+ "zone",
+ "PKEY",
+ gettext_noop ("spezifies the public key of the zone to look in"),
+ &pkey),
+
GNUNET_GETOPT_OPTION_END
};
is_public = -1;
is_shadow = -1;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "add", NULL,
- gettext_noop ("add record"), 0,
- &GNUNET_GETOPT_set_one, &add},
- {'d', "delete", NULL,
- gettext_noop ("delete record"), 0,
- &GNUNET_GETOPT_set_one, &del},
- {'D', "display", NULL,
- gettext_noop ("display records"), 0,
- &GNUNET_GETOPT_set_one, &list},
- {'e', "expiration", "TIME",
- gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1,
- &GNUNET_GETOPT_set_string, &expirationstring},
- {'i', "nick", "NICKNAME",
- gettext_noop ("set the desired nick name for the zone"), 1,
- &GNUNET_GETOPT_set_string, &nickstring},
- {'m', "monitor", NULL,
- gettext_noop ("monitor changes in the namestore"), 0,
- &GNUNET_GETOPT_set_one, &monitor},
- {'n', "name", "NAME",
- gettext_noop ("name of the record to add/delete/display"), 1,
- &GNUNET_GETOPT_set_string, &name},
- {'r', "reverse", "PKEY",
- gettext_noop ("determine our name for the given PKEY"), 1,
- &GNUNET_GETOPT_set_string, &reverse_pkey},
- {'t', "type", "TYPE",
- gettext_noop ("type of the record to add/delete/display"), 1,
- &GNUNET_GETOPT_set_string, &typestring},
- {'u', "uri", "URI",
- gettext_noop ("URI to import into our zone"), 1,
- &GNUNET_GETOPT_set_string, &uri},
- {'V', "value", "VALUE",
- gettext_noop ("value of the record to add/delete"), 1,
- &GNUNET_GETOPT_set_string, &value},
- {'p', "public", NULL,
- gettext_noop ("create or list public record"), 0,
- &GNUNET_GETOPT_set_one, &is_public},
- {'s', "shadow", NULL,
- gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), 0,
- &GNUNET_GETOPT_set_one, &is_shadow},
- {'z', "zone", "EGO",
- gettext_noop ("name of the ego controlling the zone"), 1,
- &GNUNET_GETOPT_set_string, &ego_name},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('a',
+ "add",
+ gettext_noop ("add record"),
+ &add),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "delete",
+ gettext_noop ("delete record"),
+ &del),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "display",
+ gettext_noop ("display records"),
+ &list),
+
+ GNUNET_GETOPT_OPTION_STRING ('e',
+ "expiration",
+ "TIME",
+ gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"),
+ &expirationstring),
+
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "nick",
+ "NICKNAME",
+ gettext_noop ("set the desired nick name for the zone"),
+ &nickstring),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("monitor changes in the namestore"),
+ &monitor),
+
+ GNUNET_GETOPT_OPTION_STRING ('n',
+ "name",
+ "NAME",
+ gettext_noop ("name of the record to add/delete/display"),
+ &name),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "reverse",
+ "PKEY",
+ gettext_noop ("determine our name for the given PKEY"),
+ &reverse_pkey),
+
+
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("type of the record to add/delete/display"),
+ &typestring),
+
+ GNUNET_GETOPT_OPTION_STRING ('u',
+ "uri",
+ "URI",
+ gettext_noop ("URI to import into our zone"),
+ &uri),
+
+ GNUNET_GETOPT_OPTION_STRING ('V',
+ "value",
+ "VALUE",
+ gettext_noop ("value of the record to add/delete"),
+ &value),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "public",
+ gettext_noop ("create or list public record"),
+ &is_public),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "shadow",
+ gettext_noop ("create shadow record (only valid if all other records of the same type have expired"),
+ &is_shadow),
+
+ GNUNET_GETOPT_OPTION_STRING ('z',
+ "zone",
+ "EGO",
+ gettext_noop ("name of the ego controlling the zone"),
+ &ego_name),
+
GNUNET_GETOPT_OPTION_END
};
/**
* Should we run autoconfiguration?
*/
-static unsigned int do_auto;
+static int do_auto;
/**
* Handle to a NAT test operation.
main (int argc,
char *const argv[])
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "auto", NULL,
- gettext_noop ("run autoconfiguration"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &do_auto },
- {'S', "section", "NAME",
- gettext_noop ("section name providing the configuration for the adapter"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name },
- {'t', "tcp", NULL,
- gettext_noop ("use TCP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp },
- {'u', "udp", NULL,
- gettext_noop ("use UDP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_udp },
- {'w', "write", NULL,
- gettext_noop ("write configuration file (for autoconfiguration)"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &write_cfg },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('a',
+ "auto",
+ gettext_noop ("run autoconfiguration"),
+ &do_auto),
+
+ GNUNET_GETOPT_OPTION_STRING ('S',
+ "section",
+ "NAME",
+ gettext_noop ("section name providing the configuration for the adapter"),
+ §ion_name),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('t',
+ "tcp",
+ gettext_noop ("use TCP"),
+ &use_tcp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "udp",
+ gettext_noop ("use UDP"),
+ &use_udp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('w',
+ "write",
+ gettext_noop ("write configuration file (for autoconfiguration)"),
+ &write_cfg),
GNUNET_GETOPT_OPTION_END
};
/**
* Should we actually bind to #bind_addr and receive and process STUN requests?
*/
-static unsigned int do_stun;
+static int do_stun;
/**
* Handle to NAT operation.
main (int argc,
char *const argv[])
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'i', "in", "ADDRESS",
- gettext_noop ("which IP and port are we locally using to bind/listen to"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &local_addr },
- {'r', "remote", "ADDRESS",
- gettext_noop ("which remote IP and port should be asked for connection reversal"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &remote_addr },
- {'S', "section", NULL,
- gettext_noop ("name of configuration section to find additional options, such as manual host punching data"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name },
- {'s', "stun", NULL,
- gettext_noop ("enable STUN processing"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &do_stun },
- {'t', "tcp", NULL,
- gettext_noop ("use TCP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp },
- {'u', "udp", NULL,
- gettext_noop ("use UDP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_udp },
- {'W', "watch", NULL,
- gettext_noop ("watch for connection reversal requests"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &listen_reversal },
- GNUNET_GETOPT_OPTION_END
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "in",
+ "ADDRESS",
+ gettext_noop ("which IP and port are we locally using to bind/listen to"),
+ &local_addr),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "remote",
+ "ADDRESS",
+ gettext_noop ("which remote IP and port should be asked for connection reversal"),
+ &remote_addr),
+
+ GNUNET_GETOPT_OPTION_STRING ('S',
+ "section",
+ NULL,
+ gettext_noop ("name of configuration section to find additional options, such as manual host punching data"),
+ §ion_name),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "stun",
+ gettext_noop ("enable STUN processing"),
+ &do_stun),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('t',
+ "tcp",
+ gettext_noop ("use TCP"),
+ &use_tcp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "udp",
+ gettext_noop ("use UDP"),
+ &use_udp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('W',
+ "watch",
+ gettext_noop ("watch for connection reversal requests"),
+ &listen_reversal),
+ GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK !=
/**
* Be verbose (configuration option)
*/
-static int verbose;
+static unsigned int verbose;
/**
* Name of the file with the hosts to run the test over (configuration option)
int
main (int argc, char *const *argv)
{
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'C', "connections", "COUNT",
- gettext_noop ("limit to the number of connections to NSE services, 0 for none"),
- 1, &GNUNET_GETOPT_set_uint, &connection_limit},
- {'d', "details", "FILENAME",
- gettext_noop ("name of the file for writing connection information and statistics"),
- 1, &GNUNET_GETOPT_set_string, &data_filename},
- {'H', "hosts", "FILENAME",
- gettext_noop ("name of the file with the login information for the testbed"),
- 1, &GNUNET_GETOPT_set_string, &hosts_file},
- {'o', "output", "FILENAME",
- gettext_noop ("name of the file for writing the main results"),
- 1, &GNUNET_GETOPT_set_string, &output_filename},
- {'p', "peers", "NETWORKSIZESPEC",
- gettext_noop ("Number of peers to run in each round, separated by commas"),
- 1, &GNUNET_GETOPT_set_string, &num_peer_spec},
- {'V', "verbose", NULL,
- gettext_noop ("be verbose (print progress information)"),
- 0, &GNUNET_GETOPT_increment_value, &verbose},
- {'w', "wait", "DELAY",
- gettext_noop ("delay between rounds"),
- 1, &GNUNET_GETOPT_set_relative_time, &wait_time},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_UINT ('C',
+ "connections",
+ "COUNT",
+ gettext_noop ("limit to the number of connections to NSE services, 0 for none"),
+ &connection_limit),
+ GNUNET_GETOPT_OPTION_STRING ('d',
+ "details",
+ "FILENAME",
+ gettext_noop ("name of the file for writing connection information and statistics"),
+ &data_filename),
+
+ GNUNET_GETOPT_OPTION_STRING ('H',
+ "hosts",
+ "FILENAME",
+ gettext_noop ("name of the file with the login information for the testbed"),
+ &hosts_file),
+
+ GNUNET_GETOPT_OPTION_STRING ('o',
+ "output",
+ "FILENAME",
+ gettext_noop ("name of the file for writing the main results"),
+ &output_filename),
+
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peers",
+ "NETWORKSIZESPEC",
+ gettext_noop ("Number of peers to run in each round, separated by commas"),
+ &num_peer_spec),
+
+ GNUNET_GETOPT_OPTION_INCREMENT_VALUE ('V',
+ "verbose",
+ gettext_noop ("be verbose (print progress information)"),
+ &verbose),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('w',
+ "wait",
+ "DELAY",
+ gettext_noop ("delay between rounds"),
+ &wait_time),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'n', "numeric", NULL,
- gettext_noop ("don't resolve host names"),
- 0, &GNUNET_GETOPT_set_one, &no_resolve},
- {'q', "quiet", NULL,
- gettext_noop ("output only the identity strings"),
- 0, &GNUNET_GETOPT_set_one, &be_quiet},
- {'f', "friends", NULL,
- gettext_noop ("include friend-only information"),
- 0, &GNUNET_GETOPT_set_one, &include_friend_only},
- {'s', "self", NULL,
- gettext_noop ("output our own identity only"),
- 0, &GNUNET_GETOPT_set_one, &get_self},
- {'i', "info", NULL,
- gettext_noop ("list all known peers"),
- 0, &GNUNET_GETOPT_set_one, &get_info},
- {'d', "dump-hello", NULL,
- gettext_noop ("dump hello to file"),
- 1, &GNUNET_GETOPT_set_string, &dump_hello},
- {'g', "get-hello", NULL,
- gettext_noop ("also output HELLO uri(s)"),
- 0, &GNUNET_GETOPT_set_one, &get_uri},
- {'p', "put-hello", "HELLO",
- gettext_noop ("add given HELLO uri to the database"),
- 1, &GNUNET_GETOPT_set_string, &put_uri},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "numeric",
+ gettext_noop ("don't resolve host names"),
+ &no_resolve),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('q',
+ "quiet",
+ gettext_noop ("output only the identity strings"),
+ &be_quiet),
+ GNUNET_GETOPT_OPTION_SET_ONE ('f',
+ "friends",
+ gettext_noop ("include friend-only information"),
+ &include_friend_only),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "self",
+ gettext_noop ("output our own identity only"),
+ &get_self),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "info",
+ gettext_noop ("list all known peers"),
+ &get_info),
+
+ GNUNET_GETOPT_OPTION_STRING ('d',
+ "dump-hello",
+ NULL,
+ gettext_noop ("dump hello to file"),
+ &dump_hello),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('g',
+ "get-hello",
+ gettext_noop ("also output HELLO uri(s)"),
+ &get_uri),
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "put-hello",
+ "HELLO",
+ gettext_noop ("add given HELLO uri to the database"),
+ &put_uri),
+
GNUNET_GETOPT_OPTION_END
};
int ret;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'o', "output-file", "FILENAME",
- gettext_noop ("name of the file for writing statistics"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &data_filename},
- {'t', "matching-timeout", "TIMEOUT",
- gettext_noop ("wait TIMEOUT before ending the experiment"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time},
- {'p', "policy-dir", "DIRECTORY",
- gettext_noop ("directory with policy files"),
- GNUNET_YES, &GNUNET_GETOPT_set_filename, &policy_dir},
- {'s', "strings-file", "FILENAME",
- gettext_noop ("name of file with input strings"),
- GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file},
- {'H', "hosts-file", "FILENAME",
- gettext_noop ("name of file with hosts' names"),
- GNUNET_YES, &GNUNET_GETOPT_set_filename, &hosts_file},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_FILENAME ('o',
+ "output-file",
+ "FILENAME",
+ gettext_noop ("name of the file for writing statistics"),
+ &data_filename),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "matching-timeout",
+ "TIMEOUT",
+ gettext_noop ("wait TIMEOUT before ending the experiment"),
+ &search_timeout_time),
+
+ GNUNET_GETOPT_OPTION_FILENAME ('p',
+ "policy-dir",
+ "DIRECTORY",
+ gettext_noop ("directory with policy files"),
+ &policy_dir),
+
+
+ GNUNET_GETOPT_OPTION_FILENAME ('s',
+ "strings-file",
+ "FILENAME",
+ gettext_noop ("name of file with input strings"),
+ &strings_file),
+
+ GNUNET_GETOPT_OPTION_FILENAME ('H',
+ "hosts-file",
+ "FILENAME",
+ gettext_noop ("name of file with hosts' names"),
+ &hosts_file),
+
GNUNET_GETOPT_OPTION_END
};
int ret;
/**
* The port the service is running on (default 7776)
*/
-static unsigned long port = GNUNET_REST_SERVICE_PORT;
+static unsigned long long port = GNUNET_REST_SERVICE_PORT;
/**
* The listen socket of the service for IPv4
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service listens on port %lu\n",
+ "Service listens on port %llu\n",
port);
httpd = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_NO_LISTEN_SOCKET,
0,
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'p', "port", NULL,
- gettext_noop ("listen on specified port (default: 7776)"), 1,
- &GNUNET_GETOPT_set_ulong, &port},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ULONG ('p',
+ "port",
+ "PORT",
+ gettext_noop ("listen on specified port (default: 7776)"),
+ &port),
GNUNET_GETOPT_OPTION_END
};
static const char* err_page =
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'f', "filename", "NAME",
- gettext_noop ("use NAME for the name of the revocation file"),
- 1, &GNUNET_GETOPT_set_string, &filename},
- {'R', "revoke", "NAME",
- gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "),
- 1, &GNUNET_GETOPT_set_string, &revoke_ego},
- {'p', "perform", NULL,
- gettext_noop ("actually perform revocation, otherwise we just do the precomputation"),
- 0, &GNUNET_GETOPT_set_one, &perform},
- {'t', "test", "KEY",
- gettext_noop ("test if the public key KEY has been revoked"),
- 1, &GNUNET_GETOPT_set_string, &test_ego},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('f',
+ "filename",
+ "NAME",
+ gettext_noop ("use NAME for the name of the revocation file"),
+ &filename),
+
+ GNUNET_GETOPT_OPTION_STRING ('R',
+ "revoke",
+ "NAME",
+ gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "),
+ &revoke_ego),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "perform",
+ gettext_noop ("actually perform revocation, otherwise we just do the precomputation"),
+ &perform),
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "test",
+ "KEY",
+ gettext_noop ("test if the public key KEY has been revoked"),
+ &test_ego),
+
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'e', "elements", "\"key1,val1;key2,val2;...,keyn,valn;\"",
- gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."),
- 1, &GNUNET_GETOPT_set_string, &input_elements},
- {'p', "peer", "PEERID",
- gettext_noop ("[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."),
- 1, &GNUNET_GETOPT_set_string, &input_peer_id},
- {'k', "key", "TRANSACTION_ID",
- gettext_noop ("Transaction ID shared with peer."),
- 1, &GNUNET_GETOPT_set_string, &input_session_key},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('e',
+ "elements",
+ "\"key1,val1;key2,val2;...,keyn,valn;\"",
+ gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."),
+ &input_elements),
+
+ GNUNET_GETOPT_OPTION_STRING ('e',
+ "elements",
+ "\"key1,val1;key2,val2;...,keyn,valn;\"",
+ gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."),
+ &input_elements),
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peer",
+ "PEERID",
+ gettext_noop ("[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."),
+ &input_peer_id),
+
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "TRANSACTION_ID",
+ gettext_noop ("Transaction ID shared with peer."),
+ &input_session_key),
+
GNUNET_GETOPT_OPTION_END
};
/**
* Should we try to decrypt a value after the key generation?
*/
-static unsigned int decrypt = GNUNET_NO;
+static int decrypt = GNUNET_NO;
/**
* When would we like to see the operation finished?
static struct GNUNET_HashCode session_id;
-static int verbose;
+static unsigned int verbose;
static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext;
int
main (int argc, char **argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'n', "num-peers", NULL,
- gettext_noop ("number of peers in consensus"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers },
- { 'D', "delay", NULL,
- gettext_noop ("dkg start delay"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &delay },
- { 't', "timeout", NULL,
- gettext_noop ("dkg timeout"),
- GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout },
- { 'k', "threshold", NULL,
- gettext_noop ("threshold"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &threshold },
- { 'd', "decrypt", NULL,
- gettext_noop ("also profile decryption"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &decrypt },
- { 'V', "verbose", NULL,
- gettext_noop ("be more verbose (print received values)"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },
- GNUNET_GETOPT_OPTION_END
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "num-peers",
+ NULL,
+ gettext_noop ("number of peers in consensus"),
+ &num_peers),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('D',
+ "delay",
+ NULL,
+ gettext_noop ("dkg start delay"),
+ &delay),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ NULL,
+ gettext_noop ("dkg timeout"),
+ &timeout),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('k',
+ "threshold",
+ NULL,
+ gettext_noop ("threshold"),
+ &threshold),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "descrypt",
+ gettext_noop ("also profile decryption"),
+ &decrypt),
+
+
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
+
+ GNUNET_GETOPT_OPTION_END
};
delay = GNUNET_TIME_UNIT_ZERO;
timeout = GNUNET_TIME_UNIT_MINUTES;
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"keygen commit data with wrong size (%u) in consensus, "
- " %lu expected\n",
+ " %u expected\n",
element->size, sizeof (struct GNUNET_SECRETSHARING_KeygenCommitData));
return;
}
int
main (int argc, char **argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'A', "asize", NULL,
- gettext_noop ("number of element in set A-B"), 1,
- &GNUNET_GETOPT_set_uint, &asize},
- {'B', "bsize", NULL,
- gettext_noop ("number of element in set B-A"), 1,
- &GNUNET_GETOPT_set_uint, &bsize},
- {'C', "csize", NULL,
- gettext_noop ("number of common elements in A and B"), 1,
- &GNUNET_GETOPT_set_uint, &csize},
- {'k', "hash-num", NULL,
- gettext_noop ("hash num"), 1,
- &GNUNET_GETOPT_set_uint, &hash_num},
- {'s', "ibf-size", NULL,
- gettext_noop ("ibf size"), 1,
- &GNUNET_GETOPT_set_uint, &ibf_size},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('A',
+ "asize",
+ NULL,
+ gettext_noop ("number of element in set A-B"),
+ &asize),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('B',
+ "bsize",
+ NULL,
+ gettext_noop ("number of element in set B-A"),
+ &bsize),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('C',
+ "csize",
+ NULL,
+ gettext_noop ("number of common elements in A and B"),
+ &csize),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('k',
+ "hash-num",
+ NULL,
+ gettext_noop ("hash num"),
+ &hash_num),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('s',
+ "ibf-size",
+ NULL,
+ gettext_noop ("ibf size"),
+ &ibf_size),
+
GNUNET_GETOPT_OPTION_END
};
+
GNUNET_PROGRAM_run2 (argc, argv, "gnunet-consensus-ibf",
"help",
options, &run, NULL, GNUNET_YES);
static struct GNUNET_SET_ListenHandle *set_listener;
static int byzantine;
-static int force_delta;
-static int force_full;
+static unsigned int force_delta;
+static unsigned int force_full;
static unsigned int element_size = 32;
/**
int
main (int argc, char **argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'A', "num-first", NULL,
- gettext_noop ("number of values"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_a },
- { 'B', "num-second", NULL,
- gettext_noop ("number of values"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_b },
- { 'b', "byzantine", NULL,
- gettext_noop ("use byzantine mode"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &byzantine },
- { 'f', "force-full", NULL,
- gettext_noop ("force sending full set"),
- GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
- { 'd', "force-delta", NULL,
- gettext_noop ("number delta operation"),
- GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },
- { 'C', "num-common", NULL,
- gettext_noop ("number of values"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c },
- { 'x', "operation", NULL,
- gettext_noop ("operation to execute"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str },
- { 'w', "element-size", NULL,
- gettext_noop ("element size"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &element_size },
- { 's', "statistics", NULL,
- gettext_noop ("write statistics to file"),
- GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_UINT ('A',
+ "num-first",
+ NULL,
+ gettext_noop ("number of values"),
+ &num_a),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('B',
+ "num-second",
+ NULL,
+ gettext_noop ("number of values"),
+ &num_b),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('b',
+ "byzantine",
+ gettext_noop ("use byzantine mode"),
+ &byzantine),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('f',
+ "force-full",
+ NULL,
+ gettext_noop ("force sending full set"),
+ &force_full),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('d',
+ "force-delta",
+ NULL,
+ gettext_noop ("number delta operation"),
+ &force_delta),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('C',
+ "num-common",
+ NULL,
+ gettext_noop ("number of values"),
+ &num_c),
+
+ GNUNET_GETOPT_OPTION_STRING ('x',
+ "operation",
+ NULL,
+ gettext_noop ("operation to execute"),
+ &op_str),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('w',
+ "element-size",
+ NULL,
+ gettext_noop ("element size"),
+ &element_size),
+
+ GNUNET_GETOPT_OPTION_FILENAME ('s',
+ "statistics",
+ "FILENAME",
+ gettext_noop ("write statistics to file"),
+ &statistics_filename),
+
GNUNET_GETOPT_OPTION_END
};
GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler",
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 uint64_t opt_until;
/** --limit */
-static int opt_limit;
+static long long unsigned int opt_limit;
/* global vars */
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_SET_ONE ('A',
+ "host-assign",
+ gettext_noop ("assign --name in state to --data"),
+ &op_host_assign),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('B',
+ "guest-leave",
+ gettext_noop ("say good-bye and leave somebody else's place"),
+ &op_guest_leave),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('C',
+ "host-enter",
+ gettext_noop ("create a place"),
+ &op_host_enter),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('C',
+ "host-enter",
+ gettext_noop ("create a place"),
+ &op_host_enter),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "host-leave",
+ gettext_noop ("destroy a place we were hosting"),
+ &op_host_leave),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('E',
+ "guest-enter",
+ gettext_noop ("enter somebody else's place"),
+ &op_guest_enter),
+
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('F',
+ "look-for",
+ gettext_noop ("find state matching name prefix"),
+ &op_look_for),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('H',
+ "replay-latest",
+ gettext_noop ("replay history of messages up to the given --limit"),
+ &op_replay_latest),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('N',
+ "host-reconnect",
+ gettext_noop ("reconnect to a previously created place"),
+ &op_host_reconnect),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('P',
+ "host-announce",
+ gettext_noop ("publish something to a place we are hosting"),
+ &op_host_announce),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('R',
+ "guest-reconnect",
+ gettext_noop ("reconnect to a previously entered place"),
+ &op_guest_reconnect),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('S',
+ "look-at",
+ gettext_noop ("search for state matching exact name"),
+ &op_look_at),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('T',
+ "guest-talk",
+ gettext_noop ("submit something to somebody's place"),
+ &op_guest_talk),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('U',
+ "status",
+ gettext_noop ("list of egos and subscribed places"),
+ &op_status),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('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_SET_ONE ('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_SET_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_SET_ULONG ('s',
+ "start",
+ NULL,
+ gettext_noop ("start message ID for history replay"),
+ &opt_start),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('w',
+ "welcome",
+ gettext_noop ("respond to entry requests by admitting all guests"),
+ &opt_welcome),
+
+ GNUNET_GETOPT_OPTION_SET_ULONG ('u',
+ "until",
+ NULL,
+ gettext_noop ("end message ID for history replay"),
+ &opt_until),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('y',
+ "deny",
+ gettext_noop ("respond to entry requests by refusing all guests"),
+ &opt_deny),
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'n', "name", "NAME",
- gettext_noop ("limit output to statistics for the given NAME"), 1,
- &GNUNET_GETOPT_set_string, &name},
- {'p', "persistent", NULL,
- gettext_noop ("make the value being set persistent"), 0,
- &GNUNET_GETOPT_set_one, &persistent},
- {'s', "subsystem", "SUBSYSTEM",
- gettext_noop ("limit output to the given SUBSYSTEM"), 1,
- &GNUNET_GETOPT_set_string, &subsystem},
- {'q', "quiet", NULL,
- gettext_noop ("just print the statistics value"), 0,
- &GNUNET_GETOPT_set_one, &quiet},
- {'w', "watch", NULL,
- gettext_noop ("watch value continuously"), 0,
- &GNUNET_GETOPT_set_one, &watch},
- {'r', "remote", NULL,
- gettext_noop ("connect to remote host"), 1,
- &GNUNET_GETOPT_set_string, &remote_host},
- {'o', "port", NULL,
- gettext_noop ("port for remote host"), 1,
- &GNUNET_GETOPT_set_uint, &remote_port},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_STRING ('n',
+ "name",
+ "NAME",
+ gettext_noop ("limit output to statistics for the given NAME"),
+ &name),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "persistent",
+ gettext_noop ("make the value being set persistent"),
+ &persistent),
+
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "subsystem",
+ "SUBSYSTEM",
+ gettext_noop ("limit output to the given SUBSYSTEM"),
+ &subsystem),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('q',
+ "quiet",
+ gettext_noop ("just print the statistics value"),
+ &quiet),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('w',
+ "watch",
+ gettext_noop ("watch value continuously"),
+ &watch),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "remote",
+ "REMOTE",
+ gettext_noop ("connect to remote host"),
+ &remote_host),
+ GNUNET_GETOPT_OPTION_SET_ULONG ('o',
+ "port",
+ "PORT",
+ gettext_noop ("port for remote host"),
+ &remote_port),
GNUNET_GETOPT_OPTION_END
};
remote_port = 0;
/**
* The number of peers to include in the topology
*/
-static int num_peers;
+static unsigned int num_peers;
/**
* program result
main (int argc, char *const argv[])
{
struct GNUNET_GETOPT_CommandLineOption option[] = {
- {'p', "num-peers", "COUNT",
- gettext_noop ("create COUNT number of peers"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers},
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "num-peers",
+ "COUNT",
+ gettext_noop ("create COUNT number of peers"),
+ &num_peers),
GNUNET_GETOPT_OPTION_END
};
+
int ret;
exit_result = GNUNET_SYSERR;
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'p', "num-peers", "COUNT",
- gettext_noop ("create COUNT number of peers"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers},
- {'e', "num-errors", "COUNT",
- gettext_noop ("tolerate COUNT number of continious timeout failures"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails},
- {'n', "non-interactive", NULL,
- gettext_noop ("run profiler in non-interactive mode where upon "
- "testbed setup the profiler does not wait for a "
- "keystroke but continues to run until a termination "
- "signal is received"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &noninteractive},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('p',
+ "num-peers",
+ "COUNT",
+ gettext_noop ("create COUNT number of peers"),
+ &num_peers),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('e',
+ "num-errors",
+ "COUNT",
+ gettext_noop ("tolerate COUNT number of continious timeout failures"),
+ &num_cont_fails),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "non-interactive",
+ gettext_noop ("run profiler in non-interactive mode where upon "
+ "testbed setup the profiler does not wait for a "
+ "keystroke but continues to run until a termination "
+ "signal is received"),
+ &noninteractive),
+
#if !ENABLE_SUPERMUC
- {'H', "hosts", "FILENAME",
- gettext_noop ("name of the file with the login information for the testbed"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &hosts_file},
+ GNUNET_GETOPT_OPTION_STRING ('H',
+ "hosts",
+ "FILENAME",
+ gettext_noop ("name of the file with the login information for the testbed"),
+ &hosts_file),
#endif
GNUNET_GETOPT_OPTION_END
};
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'C', "cfg", NULL, gettext_noop ("create unique configuration files"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &create_cfg},
- {'k', "key", "FILENAME", gettext_noop ("extract hostkey file from pre-computed hostkey list"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &create_hostkey},
- {'n', "number", "NUMBER", gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &create_no},
- {'t', "template", "FILENAME", gettext_noop ("configuration template"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template},
- {'r', "run", "SERVICE", gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &run_service_name},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('C',
+ "cfg",
+ gettext_noop ("create unique configuration files"),
+ &create_cfg),
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "FILENAME",
+ gettext_noop ("extract hostkey file from pre-computed hostkey list"),
+ &create_hostkey),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "number",
+ "NUMBER",
+ gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"),
+ &create_no),
+
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "template",
+ "FILENAME",
+ gettext_noop ("configuration template"),
+ &create_cfg_template),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "run",
+ "SERVICE",
+ gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
+ &run_service_name),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
static unsigned int nskip;
static int result;
-
-
-
-
/**
* Main run function.
*
int main (int argc, char *argv[])
{
struct GNUNET_GETOPT_CommandLineOption option[] = {
- {'n', "num-keys", "COUNT",
- gettext_noop ("list COUNT number of keys"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &nkeys},
- {'s', "skip", "COUNT",
- gettext_noop ("skip COUNT number of keys in the beginning"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &nskip},
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "num-keys",
+ "COUNT",
+ gettext_noop ("list COUNT number of keys"),
+ &nkeys),
GNUNET_GETOPT_OPTION_END
};
int ret;
/**
* Selected level of verbosity.
*/
-static int verbosity;
+static unsigned int verbosity;
/**
benchmark_iterations = DEFAULT_ITERATION_COUNT;
benchmark_running = GNUNET_NO;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-
- { 's', "send", NULL,
- gettext_noop ("send data to peer"),
- 0, &GNUNET_GETOPT_set_one, &benchmark_send},
- { 'r', "receive", NULL, gettext_noop
- ("receive data from peer"), 0,
- &GNUNET_GETOPT_set_one, &benchmark_receive},
- { 'i', "iterations", NULL, gettext_noop
- ("iterations"), 1,
- &GNUNET_GETOPT_set_uint, &benchmark_iterations},
- { 'n', "number", NULL, gettext_noop
- ("number of messages to send"), 1,
- &GNUNET_GETOPT_set_uint, &benchmark_count},
- { 'm', "messagesize", NULL, gettext_noop
- ("message size to use"), 1,
- &GNUNET_GETOPT_set_uint, &benchmark_size},
- { 'p', "peer", "PEER",
- gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
- &cpid },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "send",
+ gettext_noop ("send data to peer"),
+ &benchmark_send),
+ GNUNET_GETOPT_OPTION_SET_ONE ('r',
+ "receive",
+ gettext_noop ("receive data from peer"),
+ &benchmark_receive),
+ GNUNET_GETOPT_OPTION_SET_UINT ('i',
+ "iterations",
+ NULL,
+ gettext_noop ("iterations"),
+ &benchmark_iterations),
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "number",
+ NULL,
+ gettext_noop ("number of messages to send"),
+ &benchmark_count),
+ GNUNET_GETOPT_OPTION_SET_UINT ('m',
+ "messagesize",
+ NULL,
+ gettext_noop ("message size to use"),
+ &benchmark_size),
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peer",
+ "PEER",
+ gettext_noop ("peer identity"),
+ &cpid),
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
/**
* Selected level of verbosity.
*/
-static int verbosity;
+static unsigned int verbosity;
/**
* Resolver process handle.
char * const *argv)
{
int res;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'a', "all", NULL,
- gettext_noop ("print information for all peers (instead of only connected peers)"),
- 0, &GNUNET_GETOPT_set_one, &iterate_all },
- { 'b', "benchmark", NULL,
- gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
- 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
- { 'D', "disconnect",
- NULL, gettext_noop ("disconnect from a peer"), 0,
- &GNUNET_GETOPT_set_one, &do_disconnect },
- { 'i', "information", NULL,
- gettext_noop ("provide information about all current connections (once)"),
- 0, &GNUNET_GETOPT_set_one, &iterate_connections },
- { 'm', "monitor", NULL,
- gettext_noop ("provide information about all current connections (continuously)"),
- 0, &GNUNET_GETOPT_set_one, &monitor_connections },
- { 'e', "events", NULL,
- gettext_noop ("provide information about all connects and disconnect events (continuously)"),
- 0, &GNUNET_GETOPT_set_one, &monitor_connects },
- { 'n', "numeric",
- NULL, gettext_noop ("do not resolve hostnames"), 0,
- &GNUNET_GETOPT_set_one, &numeric },
- { 'p', "peer", "PEER",
- gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
- &cpid },
- { 'P', "plugins", NULL,
- gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one,
- &monitor_plugins },
- { 's', "send", NULL, gettext_noop
- ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
- &GNUNET_GETOPT_set_one, &benchmark_send },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('a',
+ "all",
+ gettext_noop ("print information for all peers (instead of only connected peers)"),
+ &iterate_all),
+ GNUNET_GETOPT_OPTION_SET_ONE ('b',
+ "benchmark",
+ gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
+ &benchmark_receive),
+ GNUNET_GETOPT_OPTION_SET_ONE ('D',
+ "disconnect",
+ gettext_noop ("disconnect from a peer"),
+ &do_disconnect),
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "information",
+ gettext_noop ("provide information about all current connections (once)"),
+ &iterate_connections),
+ GNUNET_GETOPT_OPTION_SET_ONE ('m',
+ "monitor",
+ gettext_noop ("provide information about all current connections (continuously)"),
+ &monitor_connections),
+ GNUNET_GETOPT_OPTION_SET_ONE ('e',
+ "events",
+ gettext_noop ("provide information about all connects and disconnect events (continuously)"),
+ &monitor_connects),
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "numeric",
+ gettext_noop ("do not resolve hostnames"),
+ &numeric),
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peer",
+ "PEER",
+ gettext_noop ("peer identity"),
+ &cpid),
+ GNUNET_GETOPT_OPTION_SET_ONE ('P',
+ "plugins",
+ gettext_noop ("monitor plugin sessions"),
+ &monitor_plugins),
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "send",
+ gettext_noop
+ ("send data for benchmarking to the other peer (until CTRL-C)"),
+ &benchmark_send),
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_GETOPT_CommandLineOption service_options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_fn),
- {'d', "daemonize", NULL,
- gettext_noop ("do daemonize (detach from terminal)"), 0,
- GNUNET_GETOPT_set_one, &do_daemonize},
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "daemonize",
+ gettext_noop ("do daemonize (detach from terminal)"),
+ &do_daemonize),
GNUNET_GETOPT_OPTION_HELP (NULL),
GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
GNUNET_GETOPT_OPTION_LOGFILE (&logfile),
This code was heavily modified for GNUnet.
-Copyright Copyright (C) 2006 Christian Grothoff
+Copyright Copyright (C) 2006, 2017 Christian Grothoff
*/
/**
}
}
+
static int
-GNgetopt_long (int argc, char *const *argv, const char *options,
- const struct GNoption *long_options, int *opt_index)
+GNgetopt_long (int argc,
+ char *const *argv,
+ const char *options,
+ const struct GNoption *long_options,
+ int *opt_index)
{
return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
int
GNUNET_GETOPT_run (const char *binaryOptions,
const struct GNUNET_GETOPT_CommandLineOption *allOptions,
- unsigned int argc, char *const *argv)
+ unsigned int argc,
+ char *const *argv)
{
struct GNoption *long_options;
struct GNUNET_GETOPT_CommandLineProcessorContext clpc;
int count;
- int i;
char *shorts;
int spos;
int cont;
int c;
+ uint8_t *seen;
GNUNET_assert (argc > 0);
GNoptind = 0;
clpc.allOptions = allOptions;
clpc.argv = argv;
clpc.argc = argc;
- count = 0;
- while (allOptions[count].name != NULL)
- count++;
- long_options = GNUNET_malloc (sizeof (struct GNoption) * (count + 1));
+ for (count = 0; NULL != allOptions[count].name; count++) ;
+
+ long_options = GNUNET_new_array (count + 1,
+ struct GNoption);
+ seen = GNUNET_new_array (count,
+ uint8_t);
shorts = GNUNET_malloc (count * 2 + 1);
spos = 0;
- for (i = 0; i < count; i++)
+ for (unsigned i = 0; i < count; i++)
{
long_options[i].name = allOptions[i].name;
long_options[i].has_arg = allOptions[i].require_argument;
long_options[count].val = '\0';
shorts[spos] = '\0';
cont = GNUNET_OK;
+
/* main getopt loop */
- while (cont == GNUNET_OK)
+ while (GNUNET_OK == cont)
{
int option_index = 0;
+ unsigned int i;
- c = GNgetopt_long (argc, argv, shorts, long_options, &option_index);
-
+ c = GNgetopt_long (argc, argv,
+ shorts,
+ long_options,
+ &option_index);
if (c == GNUNET_SYSERR)
break; /* No more flags to process */
clpc.currentArgument = GNoptind - 1;
if ((char) c == allOptions[i].shortName)
{
- cont =
- allOptions[i].processor (&clpc, allOptions[i].scls,
- allOptions[i].name, GNoptarg);
+ cont = allOptions[i].processor (&clpc,
+ allOptions[i].scls,
+ allOptions[i].name,
+ GNoptarg);
+ seen[i] = 1;
break;
}
}
if (i == count)
{
- FPRINTF (stderr, _("Use %s to get a list of options.\n"), "--help");
+ FPRINTF (stderr,
+ _("Use %s to get a list of options.\n"),
+ "--help");
cont = GNUNET_SYSERR;
}
}
-
GNUNET_free (shorts);
GNUNET_free (long_options);
- if (cont != GNUNET_OK)
+
+ if (GNUNET_YES == cont)
{
- return cont;
+ for (count = 0; NULL != allOptions[count].name; count++)
+ if ( (0 == seen[count]) &&
+ (allOptions[count].option_mandatory) )
+ {
+ FPRINTF (stderr,
+ _("Missing mandatory option `%s'.\n"),
+ allOptions[count].name);
+ cont = GNUNET_SYSERR;
+ }
}
+ GNUNET_free (seen);
+
+ /* call cleaners, if available */
+ for (count = 0; NULL != allOptions[count].name; count++)
+ if (NULL != allOptions[count].cleaner)
+ allOptions[count].cleaner (allOptions[count].scls);
+
+ if (GNUNET_OK != cont)
+ return cont;
return GNoptind;
}
* @param value not used (NULL)
* @return #GNUNET_NO (do not continue, not an error)
*/
-int
-GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value)
+static int
+print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
const char *version = scls;
}
+/**
+ * Define the option to print the version of
+ * the application (-v option)
+ *
+ * @param version string with the version number
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_VERSION (const char *version)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'v',
+ .name = "version",
+ .description = gettext_noop("print the version number"),
+ .processor = &print_version,
+ .scls = (void *) version
+ };
+ return clo;
+}
+
+
/**
* At what offset does the help text start?
*/
* @param value not used (NULL)
* @return #GNUNET_NO (do not continue, not an error)
*/
-int
-GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value)
+static int
+format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
const char *about = scls;
size_t slen;
}
+/**
+ * Defining the option to print the command line
+ * help text (-h option).
+ *
+ * @param about string with brief description of the application
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_HELP (const char *about)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'h',
+ .name = "help",
+ .description = gettext_noop("print this help"),
+ .processor = format_help,
+ .scls = (void *) about
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'unsigned int' from the command line. Each
* time the option flag is given, the value is incremented by one.
* type 'int'.
*
* @param ctx command line processing context
- * @param scls additional closure (will point to the 'int')
+ * @param scls additional closure (will point to the 'unsigned int')
* @param option name of the option
* @param value not used (NULL)
* @return #GNUNET_OK
*/
-int
-GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext
- *ctx, void *scls, const char *option,
- const char *value)
+static int
+increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
- int *val = scls;
+ unsigned int *val = scls;
(*val)++;
return GNUNET_OK;
}
+/**
+ * Increment @a val each time the option flag is given by one.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val increment by 1 each time the option is present
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
+ const char *name,
+ const char *description,
+ unsigned int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .description = description,
+ .processor = &increment_value,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
+/**
+ * Define the '-V' verbosity option. Using the option more
+ * than once increments @a level each time.
+ *
+ * @param[out] level set to the verbosity level
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'V',
+ .name = "verbose",
+ .description = gettext_noop("be verbose"),
+ .processor = &increment_value,
+ .scls = (void *) level
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'int' from the command line to 1 if the
* given option is present.
* @param value not used (NULL)
* @return #GNUNET_OK
*/
-int
-GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+static int
+set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
int *val = scls;
}
+/**
+ * Allow user to specify a flag (which internally means setting
+ * an integer to 1/#GNUNET_YES/#GNUNET_OK.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to 1 if the option is present
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
+ const char *name,
+ const char *description,
+ int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .description = description,
+ .processor = &set_one,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'char *' from the command line.
* A pointer to this function should be passed as part of the
* @param value actual value of the option (a string)
* @return #GNUNET_OK
*/
-int
-GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+static int
+set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
char **val = scls;
- GNUNET_assert (value != NULL);
+ GNUNET_assert (NULL != value);
GNUNET_free_non_null (*val);
*val = GNUNET_strdup (value);
return GNUNET_OK;
}
-int
-GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+/**
+ * Allow user to specify a string.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] str set to the string
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_STRING (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ char **str)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_string,
+ .scls = (void *) str
+ };
+
+ return clo;
+}
+
+
+/**
+ * Define the '-L' log level option. Note that we do not check
+ * that the log level is valid here.
+ *
+ * @param[out] level set to the log level
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_LOGLEVEL (char **level)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'L',
+ .name = "log",
+ .argumentHelp = "LOGLEVEL",
+ .description = gettext_noop("configure logging to use LOGLEVEL"),
+ .require_argument = 1,
+ .processor = &set_string,
+ .scls = (void *) level
+ };
+
+ return clo;
+}
+
+
+/**
+ * Set an option of type 'char *' from the command line with
+ * filename expansion a la #GNUNET_STRINGS_filename_expand().
+ *
+ * @param ctx command line processing context
+ * @param scls additional closure (will point to the `char *`,
+ * which will be allocated)
+ * @param option name of the option
+ * @param value actual value of the option (a string)
+ * @return #GNUNET_OK
+ */
+static int
+set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
char **val = scls;
- GNUNET_assert (value != NULL);
+ GNUNET_assert (NULL != value);
GNUNET_free_non_null (*val);
*val = GNUNET_STRINGS_filename_expand (value);
return GNUNET_OK;
}
+
+/**
+ * Allow user to specify a filename (automatically path expanded).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] str set to the string
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_FILENAME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ char **str)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) str
+ };
+
+ return clo;
+}
+
+
+/**
+ * Allow user to specify log file name (-l option)
+ *
+ * @param[out] logfn set to the name of the logfile
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_LOGFILE (char **logfn)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'l',
+ .name = "logfile",
+ .argumentHelp = "FILENAME",
+ .description = gettext_noop ("configure logging to write logs to FILENAME"),
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) logfn
+ };
+
+ return clo;
+}
+
+
+/**
+ * Allow user to specify configuration file name (-c option)
+ *
+ * @param[out] fn set to the name of the configuration file
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_CFG_FILE (char **fn)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = 'c',
+ .name = "config",
+ .argumentHelp = "FILENAME",
+ .description = gettext_noop("use configuration file FILENAME"),
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) fn
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'unsigned long long' from the command line.
* A pointer to this function should be passed as part of the
* @param value actual value of the option as a string.
* @return #GNUNET_OK if parsing the value worked
*/
-int
-GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+static int
+set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
unsigned long long *val = scls;
- if (1 != SSCANF (value, "%llu", val))
+ if (1 != SSCANF (value,
+ "%llu",
+ val))
{
- FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option);
+ FPRINTF (stderr,
+ _("You must pass a number to the `%s' option.\n"),
+ option);
return GNUNET_SYSERR;
}
return GNUNET_OK;
}
+/**
+ * Allow user to specify an `unsigned long long`
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the value specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned long long *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_ulong,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'struct GNUNET_TIME_Relative' from the command line.
* A pointer to this function should be passed as part of the
* @param value actual value of the option as a string.
* @return #GNUNET_OK if parsing the value worked
*/
-int
-GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+static int
+set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
struct GNUNET_TIME_Relative *val = scls;
GNUNET_STRINGS_fancy_time_to_relative (value,
val))
{
- FPRINTF (stderr, _("You must pass relative time to the `%s' option.\n"), option);
+ FPRINTF (stderr,
+ _("You must pass relative time to the `%s' option.\n"),
+ option);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Allow user to specify a `struct GNUNET_TIME_Relative`
+ * (using human-readable "fancy" time).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Relative *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_relative_time,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
+/**
+ * Set an option of type 'struct GNUNET_TIME_Absolute' from the command line.
+ * A pointer to this function should be passed as part of the
+ * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
+ * of this type. It should be followed by a pointer to a value of
+ * type 'struct GNUNET_TIME_Absolute'.
+ *
+ * @param ctx command line processing context
+ * @param scls additional closure (will point to the `struct GNUNET_TIME_Absolute`)
+ * @param option name of the option
+ * @param value actual value of the option as a string.
+ * @return #GNUNET_OK if parsing the value worked
+ */
+static int
+set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
+{
+ struct GNUNET_TIME_Absolute *val = scls;
+
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_fancy_time_to_absolute (value,
+ val))
+ {
+ FPRINTF (stderr,
+ _("You must pass absolute time to the `%s' option.\n"),
+ option);
return GNUNET_SYSERR;
}
return GNUNET_OK;
}
+/**
+ * Allow user to specify a `struct GNUNET_TIME_Absolute`
+ * (using human-readable "fancy" time).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Absolute *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_absolute_time,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
/**
* Set an option of type 'unsigned int' from the command line.
* A pointer to this function should be passed as part of the
* @param value actual value of the option as a string.
* @return #GNUNET_OK if parsing the value worked
*/
-int
-GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls, const char *option, const char *value)
+static int
+set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
{
unsigned int *val = scls;
- if (1 != SSCANF (value, "%u", val))
+ if (1 != SSCANF (value,
+ "%u",
+ val))
{
- FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option);
+ FPRINTF (stderr,
+ _("You must pass a number to the `%s' option.\n"),
+ option);
return GNUNET_SYSERR;
}
return GNUNET_OK;
}
+/**
+ * Allow user to specify an unsigned integer.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the value specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_uint,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
+/**
+ * Closure for #set_base32().
+ */
+struct Base32Context
+{
+ /**
+ * Value to initialize (already allocated)
+ */
+ void *val;
+
+ /**
+ * Number of bytes expected for @e val.
+ */
+ size_t val_size;
+};
+
+
+/**
+ * Set an option of type 'unsigned int' from the command line.
+ * A pointer to this function should be passed as part of the
+ * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
+ * of this type. It should be followed by a pointer to a value of
+ * type 'unsigned int'.
+ *
+ * @param ctx command line processing context
+ * @param scls additional closure (will point to the 'unsigned int')
+ * @param option name of the option
+ * @param value actual value of the option as a string.
+ * @return #GNUNET_OK if parsing the value worked
+ */
+static int
+set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
+{
+ struct Base32Context *bc = scls;
+
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (value,
+ strlen (value),
+ bc->val,
+ bc->val_size))
+ {
+ fprintf (stderr,
+ _("Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"),
+ option);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Helper function to clean up after
+ * #GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE.
+ *
+ * @param cls value to GNUNET_free()
+ */
+static void
+free_bc (void *cls)
+{
+ GNUNET_free (cls);
+}
+
+
+/**
+ * Allow user to specify a binary value using Crockford
+ * Base32 encoding.
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val binary value decoded from Crockford Base32-encoded argument
+ * @param val_size size of @a val in bytes
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ void *val,
+ size_t val_size)
+{
+ struct Base32Context *bc = GNUNET_new (struct Base32Context);
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_base32,
+ .cleaner = &free_bc,
+ .scls = (void *) bc
+ };
+
+ bc->val = val;
+ bc->val_size = val_size;
+ return clo;
+}
+
+
+/**
+ * Make the given option mandatory.
+ *
+ * @param opt option to modify
+ * @return @a opt with the mandatory flag set.
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_MANDATORY (struct GNUNET_GETOPT_CommandLineOption opt)
+{
+ opt.option_mandatory = 1;
+ return opt;
+}
+
+
/* end of getopt_helpers.c */
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'f', "filename", NULL,
- gettext_noop ("obtain option of value as a filename (with $-expansion)"),
- 0, &GNUNET_GETOPT_set_one, &is_filename },
- { 's', "section", "SECTION",
- gettext_noop ("name of the section to access"),
- 1, &GNUNET_GETOPT_set_string, §ion },
- { 'o', "option", "OPTION",
- gettext_noop ("name of the option to access"),
- 1, &GNUNET_GETOPT_set_string, &option },
- { 'V', "value", "VALUE",
- gettext_noop ("value to set"),
- 1, &GNUNET_GETOPT_set_string, &value },
- { 'S', "list-sections", NULL,
- gettext_noop ("print available configuration sections"),
- 0, &GNUNET_GETOPT_set_one, &list_sections },
- { 'w', "rewrite", NULL,
- gettext_noop ("write configuration file that only contains delta to defaults"),
- 0, &GNUNET_GETOPT_set_one, &rewrite },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('f',
+ "filename",
+ gettext_noop ("obtain option of value as a filename (with $-expansion)"),
+ &is_filename),
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "section",
+ "SECTION",
+ gettext_noop ("name of the section to access"),
+ §ion),
+ GNUNET_GETOPT_OPTION_STRING ('o',
+ "option",
+ "OPTION",
+ gettext_noop ("name of the option to access"),
+ &option),
+ GNUNET_GETOPT_OPTION_STRING ('V',
+ "value",
+ "VALUE",
+ gettext_noop ("value to set"),
+ &value),
+ GNUNET_GETOPT_OPTION_SET_ONE ('S',
+ "list-sections",
+ gettext_noop ("print available configuration sections"),
+ &list_sections),
+ GNUNET_GETOPT_OPTION_SET_ONE ('w',
+ "rewrite",
+ gettext_noop ("write configuration file that only contains delta to defaults"),
+ &rewrite),
GNUNET_GETOPT_OPTION_END
};
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-config [OPTIONS]",
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-config [OPTIONS]",
gettext_noop ("Manipulate GNUnet configuration files"),
- options, &run, NULL)) ? 0 : ret;
+ options,
+ &run, NULL)) ? 0 : ret;
GNUNET_free ((void*) argv);
return ret;
}
/**
* Flag for listing public key.
*/
-static int list_keys_count;
+static unsigned int list_keys_count;
/**
* Flag for printing public key.
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
list_keys_count = UINT32_MAX;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'i', "iterate", "FILE",
- gettext_noop ("list keys included in a file (for testing)"),
- 0, &GNUNET_GETOPT_set_one, &list_keys },
- { 'e', "end=", "COUNT",
- gettext_noop ("number of keys to list included in a file (for testing)"),
- 1, &GNUNET_GETOPT_set_uint, &list_keys_count },
- { 'g', "generate-keys", "COUNT",
- gettext_noop ("create COUNT public-private key pairs (for testing)"),
- 1, &GNUNET_GETOPT_set_uint, &make_keys },
- { 'p', "print-public-key", NULL,
- gettext_noop ("print the public key in ASCII format"),
- 0, &GNUNET_GETOPT_set_one, &print_public_key },
- { 'E', "examples", NULL,
- gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
- 0, &GNUNET_GETOPT_set_one, &print_examples_flag },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('i',
+ "iterate",
+ gettext_noop ("list keys included in a file (for testing)"),
+ &list_keys),
+ GNUNET_GETOPT_OPTION_SET_UINT ('e',
+ "end=",
+ "COUNT",
+ gettext_noop ("number of keys to list included in a file (for testing)"),
+ &list_keys_count),
+ GNUNET_GETOPT_OPTION_SET_UINT ('g',
+ "generate-keys",
+ "COUNT",
+ gettext_noop ("create COUNT public-private key pairs (for testing)"),
+ &make_keys),
+ GNUNET_GETOPT_OPTION_SET_ONE ('p',
+ "print-public-key",
+ gettext_noop ("print the public key in ASCII format"),
+ &print_public_key),
+ GNUNET_GETOPT_OPTION_SET_ONE ('E',
+ "examples",
+ gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
+ &print_examples_flag),
GNUNET_GETOPT_OPTION_END
};
int ret;
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]",
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]",
gettext_noop ("Manipulate GNUnet private ECC key files"),
- options, &run, NULL)) ? 0 : 1;
+ options,
+ &run,
+ NULL)) ? 0 : 1;
GNUNET_free ((void*) argv);
return ret;
}
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'r', "reverse", NULL,
- gettext_noop ("perform a reverse lookup"),
- 0, &GNUNET_GETOPT_set_one, &reverse },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('r',
+ "reverse",
+ gettext_noop ("perform a reverse lookup"),
+ &reverse),
GNUNET_GETOPT_OPTION_END
};
int ret;
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'b', "bits", "BITS",
- gettext_noop ("number of bits to require for the proof of work"),
- 1, &GNUNET_GETOPT_set_ulong, &nse_work_required },
- { 'k', "keyfile", "FILE",
- gettext_noop ("file with private key, otherwise default is used"),
- 1, &GNUNET_GETOPT_set_filename, &pkfn },
- { 'o', "outfile", "FILE",
- gettext_noop ("file with proof of work, otherwise default is used"),
- 1, &GNUNET_GETOPT_set_filename, &pwfn },
- { 't', "timeout", "TIME",
- gettext_noop ("time to wait between calculations"),
- 1, &GNUNET_GETOPT_set_relative_time, &proof_find_delay },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ULONG ('b',
+ "bits",
+ "BITS",
+ gettext_noop ("number of bits to require for the proof of work"),
+ &nse_work_required),
+ GNUNET_GETOPT_OPTION_FILENAME ('k',
+ "keyfile",
+ "FILE",
+ gettext_noop ("file with private key, otherwise default is used"),
+ &pkfn),
+ GNUNET_GETOPT_OPTION_FILENAME ('o',
+ "outfile",
+ "FILE",
+ gettext_noop ("file with proof of work, otherwise default is used"),
+ &pwfn),
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
+ "timeout",
+ "TIME",
+ gettext_noop ("time to wait between calculations"),
+ &proof_find_delay),
GNUNET_GETOPT_OPTION_END
};
int ret;
GNUNET_PROGRAM_run (argc, argv,
"gnunet-scrypt [OPTIONS] prooffile",
gettext_noop ("Manipulate GNUnet proof of work files"),
- options, &run, NULL)) ? 0 : 1;
+ options,
+ &run,
+ NULL)) ? 0 : 1;
GNUNET_free ((void*) argv);
GNUNET_free_non_null (pwfn);
return ret;
struct GNUNET_GETOPT_CommandLineOption service_options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename),
- {'d', "daemonize", NULL,
- gettext_noop ("do daemonize (detach from terminal)"), 0,
- GNUNET_GETOPT_set_one, &do_daemonize},
+ GNUNET_GETOPT_OPTION_SET_ONE ('d',
+ "daemonize",
+ gettext_noop ("do daemonize (detach from terminal)"),
+ &do_daemonize),
GNUNET_GETOPT_OPTION_HELP (NULL),
GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
GNUNET_GETOPT_OPTION_LOGFILE (&logfile),
GNUNET_GETOPT_OPTION_END
};
- if (5 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 5, myargv))
+ if (5 != GNUNET_GETOPT_run ("test_getopt",
+ logoptionlist,
+ 5, myargv))
{
GNUNET_break (0);
return 1;
}
- GNUNET_assert (fn != NULL);
- if ((0 != strcmp (level, "WARNING")) || (0 != strcmp (fn, "filename")))
+ GNUNET_assert (NULL != fn);
+ if ( (0 != strcmp (level, "WARNING")) ||
+ (NULL == strstr (fn, "/filename")) )
{
GNUNET_break (0);
GNUNET_free (level);
unsigned long long lnum = 0;
const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = {
- {'f', "--flag", NULL, "helptext", 0, &GNUNET_GETOPT_set_one,
- (void *) &flag},
- {'n', "--num", "ARG", "helptext", 1, &GNUNET_GETOPT_set_uint,
- (void *) &num},
- {'N', "--lnum", "ARG", "helptext", 1, &GNUNET_GETOPT_set_ulong,
- (void *) &lnum},
+ GNUNET_GETOPT_OPTION_SET_ONE ('f',
+ "--flag",
+ "helptext",
+ &flag),
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "--num",
+ "ARG",
+ "helptext",
+ &num),
+ GNUNET_GETOPT_OPTION_SET_ULONG ('N',
+ "--lnum",
+ "ARG",
+ "helptext",
+ &lnum),
GNUNET_GETOPT_OPTION_END
};
- if (6 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 6, myargv))
+ if (6 !=
+ GNUNET_GETOPT_run ("test_getopt",
+ logoptionlist,
+ 6,
+ myargv))
{
GNUNET_break (0);
return 1;
}
- if ((1 != flag) || (42 != num) || (42 != lnum))
+ if ( (1 != flag) ||
+ (42 != num) ||
+ (42 != lnum))
{
GNUNET_break (0);
return 1;
{
int errCnt = 0;
- GNUNET_log_setup ("test_getopt", "WARNING", NULL);
+ GNUNET_log_setup ("test_getopt",
+ "WARNING",
+ NULL);
/* suppress output from -h, -v options */
#ifndef MINGW
GNUNET_break (0 == CLOSE (1));
#include "platform.h"
#include "gnunet_util_lib.h"
-static int setme1, setme2;
-
-static struct GNUNET_GETOPT_CommandLineOption options1[] = {
- {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
- GNUNET_GETOPT_OPTION_END
-};
-
-static struct GNUNET_GETOPT_CommandLineOption options2[] = {
- {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
- {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
- GNUNET_GETOPT_OPTION_END
-};
-
-static struct GNUNET_GETOPT_CommandLineOption options3[] = {
- {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
- {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
- GNUNET_GETOPT_OPTION_END
-};
-
-static struct GNUNET_GETOPT_CommandLineOption options4[] = {
- {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
- {'n', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
- GNUNET_GETOPT_OPTION_END
-};
+
+static int setme1;
+
+static int setme2;
+
/**
* Main function that will be run.
*/
-
static void
-runner (void *cls, char *const *args, const char *cfgfile,
+runner (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
int *ok = cls;
GNUNET_assert (setme1 == 1);
GNUNET_assert (0 == strcmp (args[0], "extra"));
GNUNET_assert (args[1] == NULL);
- GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf"));
-
+ GNUNET_assert (NULL != strstr (cfgfile, "/test_program_data.conf"));
*ok = 0;
}
-/**
- * Main method, starts scheduler with task1,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
+
+int
+main (int argc, char *argv[])
{
int ok = 1;
-
- char *const argv[] = {
+ char *const argvx[] = {
"test_program",
"-c",
"test_program_data.conf",
"extra",
NULL
};
+ struct GNUNET_GETOPT_CommandLineOption options1[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "name",
+ "description",
+ &setme1),
+ GNUNET_GETOPT_OPTION_END
+ };
+ struct GNUNET_GETOPT_CommandLineOption options2[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "name",
+ "description",
+ &setme1),
+ GNUNET_GETOPT_OPTION_SET_ONE ('N',
+ "number",
+ "description",
+ &setme2),
+ GNUNET_GETOPT_OPTION_END
+ };
+ struct GNUNET_GETOPT_CommandLineOption options3[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('N',
+ "number",
+ "description",
+ &setme1),
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "name",
+ "description",
+ &setme2),
+ GNUNET_GETOPT_OPTION_END
+ };
+ struct GNUNET_GETOPT_CommandLineOption options4[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "name",
+ "description",
+ &setme1),
+ GNUNET_GETOPT_OPTION_SET_ONE ('n',
+ "name",
+ "description",
+ &setme2),
+ GNUNET_GETOPT_OPTION_END
+ };
+
+ GNUNET_log_setup ("test_program",
+ "WARNING",
+ NULL);
GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
- options1, &runner, &ok));
+ GNUNET_PROGRAM_run (7, argvx,
+ "test_program",
+ "A test",
+ options1,
+ &runner, &ok));
GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
- options2, &runner, &ok));
+ GNUNET_PROGRAM_run (7, argvx,
+ "test_program", "A test",
+ options2,
+ &runner, &ok));
GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
- options3, &runner, &ok));
+ GNUNET_PROGRAM_run (7, argvx,
+ "test_program", "A test",
+ options3,
+ &runner, &ok));
GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
- options4, &runner, &ok));
+ GNUNET_PROGRAM_run (7, argvx,
+ "test_program", "A test",
+ options4,
+ &runner, &ok));
return ok;
}
-int
-main (int argc, char *argv[])
-{
- int ret = 0;
-
- GNUNET_log_setup ("test_program", "WARNING", NULL);
- ret += check ();
-
- return ret;
-}
-
/* end of test_program.c */
/**
* Selected level of verbosity.
*/
-static int verbosity;
+static unsigned int verbosity;
/**
* Global return value.
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'4', "ipv4", NULL,
- gettext_noop ("request that result should be an IPv4 address"),
- 0, &GNUNET_GETOPT_set_one, &ipv4},
- {'6', "ipv6", NULL,
- gettext_noop ("request that result should be an IPv6 address"),
- 0, &GNUNET_GETOPT_set_one, &ipv6},
- {'d', "duration", "TIME",
- gettext_noop ("how long should the mapping be valid for new tunnels?"),
- 1, &GNUNET_GETOPT_set_relative_time, &duration},
- {'i', "ip", "IP",
- gettext_noop ("destination IP for the tunnel"),
- 1, &GNUNET_GETOPT_set_string, &target_ip},
- {'p', "peer", "PEERID",
- gettext_noop ("peer offering the service we would like to access"),
- 1, &GNUNET_GETOPT_set_string, &peer_id},
- {'s', "service", "NAME",
- gettext_noop ("name of the service we would like to access"),
- 1, &GNUNET_GETOPT_set_string, &service_name},
- {'t', "tcp", NULL,
- gettext_noop ("service is offered via TCP"),
- 0, &GNUNET_GETOPT_set_one, &tcp},
- {'u', "udp", NULL,
- gettext_noop ("service is offered via UDP"),
- 0, &GNUNET_GETOPT_set_one, &udp},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('4',
+ "ipv4",
+ gettext_noop ("request that result should be an IPv4 address"),
+ &ipv4),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('6',
+ "ipv6",
+ gettext_noop ("request that result should be an IPv6 address"),
+ &ipv6),
+
+ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('d',
+ "duration",
+ "TIME",
+ gettext_noop ("how long should the mapping be valid for new tunnels?"),
+ &duration),
+
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "ip",
+ "IP",
+ gettext_noop ("destination IP for the tunnel"),
+ &target_ip),
+
+ GNUNET_GETOPT_OPTION_STRING ('p',
+ "peer",
+ "PEERID",
+ gettext_noop ("peer offering the service we would like to access"),
+ &peer_id),
+
+ GNUNET_GETOPT_OPTION_STRING ('s',
+ "service",
+ "NAME",
+ gettext_noop ("name of the service we would like to access"),
+ &service_name),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('t',
+ "tcp",
+ gettext_noop ("service is offered via TCP"),
+ &tcp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "udp",
+ gettext_noop ("service is offered via UDP"),
+ &udp),
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
+
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))