diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-07 20:54:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-07 20:54:53 +0000 |
commit | ed28dd2141e77aa073d81089cb5a07e0a0fc013c (patch) | |
tree | 51caa9ce91662983b6f44fdd3f0a0045a1bf2b32 /src | |
parent | 69667eaa594670ae1bb209fda2761798426ec7b1 (diff) | |
download | gnunet-ed28dd2141e77aa073d81089cb5a07e0a0fc013c.tar.gz gnunet-ed28dd2141e77aa073d81089cb5a07e0a0fc013c.zip |
expand GNUNET_OS_ProjectData API to also enable de-duplcation of logic for --help
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_getopt_lib.h | 15 | ||||
-rw-r--r-- | src/include/gnunet_os_lib.h | 17 | ||||
-rw-r--r-- | src/util/getopt_helpers.c | 10 | ||||
-rw-r--r-- | 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 | |||
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | |||
83 | /** | 84 | /** |
84 | * @brief Process a command line option | 85 | * @brief Process a command line option |
85 | * | 86 | * |
@@ -89,11 +90,12 @@ struct GNUNET_GETOPT_CommandLineProcessorContext | |||
89 | * @param value argument, NULL if none was given | 90 | * @param value argument, NULL if none was given |
90 | * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort | 91 | * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort |
91 | */ | 92 | */ |
92 | typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (struct | 93 | typedef int |
93 | GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 94 | (*GNUNET_GETOPT_CommandLineOptionProcessor) (struct |
94 | void *scls, | 95 | GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
95 | const char *option, | 96 | void *scls, |
96 | const char *value); | 97 | const char *option, |
98 | const char *value); | ||
97 | 99 | ||
98 | /** | 100 | /** |
99 | * @brief Definition of a command line option. | 101 | * @brief Definition of a command line option. |
@@ -122,7 +124,8 @@ struct GNUNET_GETOPT_CommandLineOption | |||
122 | const char *description; | 124 | const char *description; |
123 | 125 | ||
124 | /** | 126 | /** |
125 | * Is an argument required? 0: #GNUNET_NO (includes optional), 1: #GNUNET_YES. | 127 | * Is an argument required? #GNUNET_NO (includes optional) or |
128 | * #GNUNET_YES (required) | ||
126 | */ | 129 | */ |
127 | int require_argument; | 130 | int require_argument; |
128 | 131 | ||
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 | |||
240 | */ | 240 | */ |
241 | const char *env_varname_alt; | 241 | const char *env_varname_alt; |
242 | 242 | ||
243 | /** | ||
244 | * E-mail address for reporting bugs. | ||
245 | */ | ||
246 | const char *bug_email; | ||
247 | |||
248 | /** | ||
249 | * Project homepage. | ||
250 | */ | ||
251 | const char *homepage; | ||
252 | |||
243 | }; | 253 | }; |
244 | 254 | ||
245 | 255 | ||
@@ -251,6 +261,13 @@ GNUNET_OS_project_data_default (void); | |||
251 | 261 | ||
252 | 262 | ||
253 | /** | 263 | /** |
264 | * @return current (actual) project data. | ||
265 | */ | ||
266 | const struct GNUNET_OS_ProjectData * | ||
267 | GNUNET_OS_project_data_get (void); | ||
268 | |||
269 | |||
270 | /** | ||
254 | * Setup OS subsystem with project data. | 271 | * Setup OS subsystem with project data. |
255 | * | 272 | * |
256 | * @param pd project data used to determine paths. | 273 | * @param pd project data used to determine paths. |
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 | |||
82 | char *scp; | 82 | char *scp; |
83 | const char *trans; | 83 | const char *trans; |
84 | const struct GNUNET_GETOPT_CommandLineOption *opt; | 84 | const struct GNUNET_GETOPT_CommandLineOption *opt; |
85 | const struct GNUNET_OS_ProjectData *pd; | ||
85 | 86 | ||
86 | if (NULL != about) | 87 | if (NULL != about) |
87 | { | 88 | { |
@@ -153,9 +154,12 @@ OUTER: | |||
153 | printf ("\n"); | 154 | printf ("\n"); |
154 | i++; | 155 | i++; |
155 | } | 156 | } |
156 | printf ("Report bugs to gnunet-developers@gnu.org.\n" | 157 | pd = GNUNET_OS_project_data_get (); |
157 | "GNUnet home page: http://www.gnu.org/software/gnunet/\n" | 158 | printf ("Report bugs to %s.\n" |
158 | "General help using GNU software: http://www.gnu.org/gethelp/\n"); | 159 | "GNUnet home page: %s\n" |
160 | "General help using GNU software: http://www.gnu.org/gethelp/\n", | ||
161 | pd->bug_email, | ||
162 | pd->homepage); | ||
159 | return GNUNET_NO; | 163 | return GNUNET_NO; |
160 | } | 164 | } |
161 | 165 | ||
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 = { | |||
58 | .project_dirname = "gnunet", | 58 | .project_dirname = "gnunet", |
59 | .binary_name = "gnunet-arm", | 59 | .binary_name = "gnunet-arm", |
60 | .env_varname = "GNUNET_PREFIX", | 60 | .env_varname = "GNUNET_PREFIX", |
61 | .bug_email = "gnunet-developers@gnu.org", | ||
62 | .homepage = "http://www.gnu.org/s/gnunet/", | ||
61 | }; | 63 | }; |
62 | 64 | ||
63 | /** | 65 | /** |
@@ -77,6 +79,16 @@ GNUNET_OS_project_data_default (void) | |||
77 | 79 | ||
78 | 80 | ||
79 | /** | 81 | /** |
82 | * @return current project data. | ||
83 | */ | ||
84 | const struct GNUNET_OS_ProjectData * | ||
85 | GNUNET_OS_project_data_get () | ||
86 | { | ||
87 | return current_pd; | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
80 | * Setup OS subsystem with project data. | 92 | * Setup OS subsystem with project data. |
81 | * | 93 | * |
82 | * @param pd project data used to determine paths | 94 | * @param pd project data used to determine paths |