expand GNUNET_OS_ProjectData API to also enable de-duplcation of logic for --help
authorChristian Grothoff <christian@grothoff.org>
Thu, 7 Apr 2016 20:54:53 +0000 (20:54 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 7 Apr 2016 20:54:53 +0000 (20:54 +0000)
src/include/gnunet_getopt_lib.h
src/include/gnunet_os_lib.h
src/util/getopt_helpers.c
src/util/os_installation.c

index 100854e0fbd57b079bb953d9afd9f39203a3b936..b04020a7057fde8e5dba8ca6dc3d108def2ffc10 100644 (file)
@@ -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;
 
index 8cd4a4578f31edfde513988df716bf9daf808850..3fa2497d6b11ee7b8a23f81d251a5e6cbef1b5ac 100644 (file)
@@ -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.
  *
index 176dc3fe16c47f9d01fa1632c9b291aba01009b8..5a0bf0565e10036d09e6e042dbc3791d8e4b663a 100644 (file)
@@ -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;
 }
 
index 030a935c116acdd7e7a03515da0b47ebe8014bc5..a3f0e63f96687b4d39eed6de2c2e82f9339253b3 100644 (file)
@@ -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.
  *