From ed28dd2141e77aa073d81089cb5a07e0a0fc013c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 Apr 2016 20:54:53 +0000 Subject: [PATCH] expand GNUNET_OS_ProjectData API to also enable de-duplcation of logic for --help --- src/include/gnunet_getopt_lib.h | 15 +++++++++------ src/include/gnunet_os_lib.h | 17 +++++++++++++++++ src/util/getopt_helpers.c | 10 +++++++--- src/util/os_installation.c | 12 ++++++++++++ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 100854e0f..b04020a70 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h @@ -80,6 +80,7 @@ struct GNUNET_GETOPT_CommandLineProcessorContext }; + /** * @brief Process a command line option * @@ -89,11 +90,12 @@ struct GNUNET_GETOPT_CommandLineProcessorContext * @param value argument, NULL if none was given * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort */ -typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (struct - GNUNET_GETOPT_CommandLineProcessorContext *ctx, - void *scls, - const char *option, - const char *value); +typedef int +(*GNUNET_GETOPT_CommandLineOptionProcessor) (struct + GNUNET_GETOPT_CommandLineProcessorContext *ctx, + void *scls, + const char *option, + const char *value); /** * @brief Definition of a command line option. @@ -122,7 +124,8 @@ struct GNUNET_GETOPT_CommandLineOption const char *description; /** - * Is an argument required? 0: #GNUNET_NO (includes optional), 1: #GNUNET_YES. + * Is an argument required? #GNUNET_NO (includes optional) or + * #GNUNET_YES (required) */ int require_argument; diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 8cd4a4578..3fa2497d6 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h @@ -240,6 +240,16 @@ struct GNUNET_OS_ProjectData */ const char *env_varname_alt; + /** + * E-mail address for reporting bugs. + */ + const char *bug_email; + + /** + * Project homepage. + */ + const char *homepage; + }; @@ -250,6 +260,13 @@ const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default (void); +/** + * @return current (actual) project data. + */ +const struct GNUNET_OS_ProjectData * +GNUNET_OS_project_data_get (void); + + /** * Setup OS subsystem with project data. * diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index 176dc3fe1..5a0bf0565 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c @@ -82,6 +82,7 @@ GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ct char *scp; const char *trans; const struct GNUNET_GETOPT_CommandLineOption *opt; + const struct GNUNET_OS_ProjectData *pd; if (NULL != about) { @@ -153,9 +154,12 @@ OUTER: printf ("\n"); i++; } - printf ("Report bugs to gnunet-developers@gnu.org.\n" - "GNUnet home page: http://www.gnu.org/software/gnunet/\n" - "General help using GNU software: http://www.gnu.org/gethelp/\n"); + pd = GNUNET_OS_project_data_get (); + printf ("Report bugs to %s.\n" + "GNUnet home page: %s\n" + "General help using GNU software: http://www.gnu.org/gethelp/\n", + pd->bug_email, + pd->homepage); return GNUNET_NO; } diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 030a935c1..a3f0e63f9 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -58,6 +58,8 @@ static const struct GNUNET_OS_ProjectData default_pd = { .project_dirname = "gnunet", .binary_name = "gnunet-arm", .env_varname = "GNUNET_PREFIX", + .bug_email = "gnunet-developers@gnu.org", + .homepage = "http://www.gnu.org/s/gnunet/", }; /** @@ -76,6 +78,16 @@ GNUNET_OS_project_data_default (void) } +/** + * @return current project data. + */ +const struct GNUNET_OS_ProjectData * +GNUNET_OS_project_data_get () +{ + return current_pd; +} + + /** * Setup OS subsystem with project data. * -- 2.25.1