aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-15 09:39:46 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-15 11:14:58 +0100
commit30eb0faa8d4894659cc90c76cc634148df86eab9 (patch)
treeb6cfb44c28bf018c575f11720e28cda06d346063
parentcd475225e4fd83fcc16b77ea1294c11428447209 (diff)
downloadgnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.tar.gz
gnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.zip
getopt major style fix, remove macro-mania with nicer typed functions
-rw-r--r--po/POTFILES.in19
-rw-r--r--src/include/gnunet_getopt_lib.h286
-rw-r--r--src/util/getopt_helpers.c450
-rw-r--r--src/util/gnunet-config.c58
-rw-r--r--src/util/gnunet-ecc.c56
-rw-r--r--src/util/gnunet-resolver.c9
-rw-r--r--src/util/gnunet-scrypt.c41
-rw-r--r--src/util/service.c7
-rw-r--r--src/util/service_new.c7
9 files changed, 652 insertions, 281 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index aea7d5ef7..b0fae9dbe 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -37,31 +37,19 @@ src/block/block.c
37src/block/plugin_block_template.c 37src/block/plugin_block_template.c
38src/block/plugin_block_test.c 38src/block/plugin_block_test.c
39src/cadet/cadet_api.c 39src/cadet/cadet_api.c
40src/cadet/cadet_api_new.c
41src/cadet/cadet_common.c
42src/cadet/cadet_path.c
43src/cadet/cadet_test_lib.c 40src/cadet/cadet_test_lib.c
44src/cadet/cadet_test_lib_new.c
45src/cadet/desirability_table.c 41src/cadet/desirability_table.c
46src/cadet/gnunet-cadet.c 42src/cadet/gnunet-cadet.c
47src/cadet/gnunet-cadet-profiler.c 43src/cadet/gnunet-cadet-profiler.c
48src/cadet/gnunet-service-cadet.c 44src/cadet/gnunet-service-cadet.c
49src/cadet/gnunet-service-cadet_channel.c 45src/cadet/gnunet-service-cadet_channel.c
50src/cadet/gnunet-service-cadet_connection.c 46src/cadet/gnunet-service-cadet_connection.c
47src/cadet/gnunet-service-cadet_core.c
51src/cadet/gnunet-service-cadet_dht.c 48src/cadet/gnunet-service-cadet_dht.c
52src/cadet/gnunet-service-cadet_hello.c 49src/cadet/gnunet-service-cadet_hello.c
53src/cadet/gnunet-service-cadet_local.c 50src/cadet/gnunet-service-cadet_paths.c
54src/cadet/gnunet-service-cadet-new.c
55src/cadet/gnunet-service-cadet-new_channel.c
56src/cadet/gnunet-service-cadet-new_connection.c
57src/cadet/gnunet-service-cadet-new_core.c
58src/cadet/gnunet-service-cadet-new_dht.c
59src/cadet/gnunet-service-cadet-new_hello.c
60src/cadet/gnunet-service-cadet-new_paths.c
61src/cadet/gnunet-service-cadet-new_peer.c
62src/cadet/gnunet-service-cadet-new_tunnels.c
63src/cadet/gnunet-service-cadet_peer.c 51src/cadet/gnunet-service-cadet_peer.c
64src/cadet/gnunet-service-cadet_tunnel.c 52src/cadet/gnunet-service-cadet_tunnels.c
65src/consensus/consensus_api.c 53src/consensus/consensus_api.c
66src/consensus/gnunet-consensus-profiler.c 54src/consensus/gnunet-consensus-profiler.c
67src/consensus/gnunet-service-consensus.c 55src/consensus/gnunet-service-consensus.c
@@ -165,7 +153,6 @@ src/fs/gnunet-service-fs_cadet_client.c
165src/fs/gnunet-service-fs_cadet_server.c 153src/fs/gnunet-service-fs_cadet_server.c
166src/fs/gnunet-service-fs_cp.c 154src/fs/gnunet-service-fs_cp.c
167src/fs/gnunet-service-fs_indexing.c 155src/fs/gnunet-service-fs_indexing.c
168src/fs/gnunet-service-fs_lc.c
169src/fs/gnunet-service-fs_pe.c 156src/fs/gnunet-service-fs_pe.c
170src/fs/gnunet-service-fs_pr.c 157src/fs/gnunet-service-fs_pr.c
171src/fs/gnunet-service-fs_push.c 158src/fs/gnunet-service-fs_push.c
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index b04020a70..cd546905e 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -97,6 +97,7 @@ typedef int
97 const char *option, 97 const char *option,
98 const char *value); 98 const char *value);
99 99
100
100/** 101/**
101 * @brief Definition of a command line option. 102 * @brief Definition of a command line option.
102 */ 103 */
@@ -141,244 +142,215 @@ struct GNUNET_GETOPT_CommandLineOption
141 142
142}; 143};
143 144
145
144/** 146/**
145 * Macro defining the option to print the command line 147 * Defining the option to print the command line
146 * help text (-h option). 148 * help text (-h option).
147 * 149 *
148 * @param about string with brief description of the application 150 * @param about string with brief description of the application
149 */ 151 */
150#define GNUNET_GETOPT_OPTION_HELP(about) \ 152struct GNUNET_GETOPT_CommandLineOption
151 { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, &GNUNET_GETOPT_format_help_, (void *) about } 153GNUNET_GETOPT_OPTION_HELP (const char *about);
152 154
153 155
154/** 156/**
155 * Macro defining the option to print the version of 157 * Define the option to print the version of
156 * the application (-v option) 158 * the application (-v option)
157 * 159 *
158 * @param version string with the version number 160 * @param version string with the version number
159 */ 161 */
160#define GNUNET_GETOPT_OPTION_VERSION(version) \ 162struct GNUNET_GETOPT_CommandLineOption
161 { 'v', "version", (const char *) NULL, gettext_noop("print the version number"), 0, &GNUNET_GETOPT_print_version_, (void *) version } 163GNUNET_GETOPT_OPTION_VERSION (const char *version);
164
162 165
163 166
164/** 167/**
165 * Allow user to specify log file name (-l option) 168 * Allow user to specify log file name (-l option)
166 * 169 *
167 * @param logfn set to the name of the logfile 170 * @param[out] logfn set to the name of the logfile
168 */ 171 */
169#define GNUNET_GETOPT_OPTION_LOGFILE(logfn) \ 172struct GNUNET_GETOPT_CommandLineOption
170 { 'l', "logfile", "LOGFILE", gettext_noop("configure logging to write logs to LOGFILE"), 1, &GNUNET_GETOPT_set_string, (void *) logfn } 173GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
171 174
172 175
173/** 176/**
174 * Allow user to specify log level (-L option) 177 * Allow user to specify a string.
175 * 178 *
176 * @param loglev set to the log level 179 * @param shortName short name of the option
180 * @param name long name of the option
181 * @param argumentHelp help text for the option argument
182 * @param description long help text for the option
183 * @param[out] str set to the string
177 */ 184 */
178#define GNUNET_GETOPT_OPTION_LOGLEVEL(loglev) \ 185struct GNUNET_GETOPT_CommandLineOption
179 { 'L', "log", "LOGLEVEL", gettext_noop("configure logging to use LOGLEVEL"), 1, &GNUNET_GETOPT_set_string, (void *) loglev } 186GNUNET_GETOPT_OPTION_STRING (char shortName,
180 187 const char *name,
188 const char *argumentHelp,
189 const char *description,
190 char **str);
181 191
182/** 192/**
183 * Get number of verbose (-V) flags 193 * Allow user to specify a filename (automatically path expanded).
184 * 194 *
185 * @param level where to store the verbosity level (should be an 'int') 195 * @param shortName short name of the option
196 * @param name long name of the option
197 * @param argumentHelp help text for the option argument
198 * @param description long help text for the option
199 * @param[out] str set to the string
186 */ 200 */
187#define GNUNET_GETOPT_OPTION_VERBOSE(level) \ 201struct GNUNET_GETOPT_CommandLineOption
188 { 'V', "verbose", (const char *) NULL, gettext_noop("be verbose"), 0, &GNUNET_GETOPT_increment_value, (void *) level } 202GNUNET_GETOPT_OPTION_FILENAME (char shortName,
203 const char *name,
204 const char *argumentHelp,
205 const char *description,
206 char **str);
189 207
190 208
191/** 209/**
192 * Get configuration file name (-c option) 210 * Allow user to specify a flag (which internally means setting
211 * an integer to 1/#GNUNET_YES/#GNUNET_OK.
193 * 212 *
194 * @param fn set to the configuration file name 213 * @param shortName short name of the option
214 * @param name long name of the option
215 * @param description long help text for the option
216 * @param[out] val set to 1 if the option is present
195 */ 217 */
196#define GNUNET_GETOPT_OPTION_CFG_FILE(fn) \ 218struct GNUNET_GETOPT_CommandLineOption
197 { 'c', "config", "FILENAME", gettext_noop("use configuration file FILENAME"), 1, &GNUNET_GETOPT_set_string, (void *) fn } 219GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
220 const char *name,
221 const char *description,
222 int *val);
198 223
199 224
200/** 225/**
201 * Marker for the end of the list of options. 226 * Allow user to specify an `unsigned int`.
227 *
228 * @param shortName short name of the option
229 * @param name long name of the option
230 * @param argumentHelp help text for the option argument
231 * @param description long help text for the option
232 * @param[out] val set to the value specified at the command line
202 */ 233 */
203#define GNUNET_GETOPT_OPTION_END \ 234struct GNUNET_GETOPT_CommandLineOption
204 { '\0', NULL, NULL, NULL, 0, NULL, NULL } 235GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
236 const char *name,
237 const char *argumentHelp,
238 const char *description,
239 unsigned int *val);
205 240
206 241
207/** 242/**
208 * Parse the command line. 243 * Allow user to specify an `unsigned long long`.
209 * 244 *
210 * @param binaryOptions Name of application with option summary 245 * @param shortName short name of the option
211 * @param allOptions defined options and handlers 246 * @param name long name of the option
212 * @param argc number of arguments in @a argv 247 * @param argumentHelp help text for the option argument
213 * @param argv actual arguments 248 * @param description long help text for the option
214 * @return index into argv with first non-option 249 * @param[out] val set to the value specified at the command line
215 * argument, or #GNUNET_SYSERR on error
216 */ 250 */
217int 251struct GNUNET_GETOPT_CommandLineOption
218GNUNET_GETOPT_run (const char *binaryOptions, 252GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
219 const struct GNUNET_GETOPT_CommandLineOption *allOptions, 253 const char *name,
220 unsigned int argc, char *const *argv); 254 const char *argumentHelp,
255 const char *description,
256 unsigned long long *val);
221 257
222 258
223/** 259/**
224 * Set an option of type 'unsigned long long' from the command line. 260 * Allow user to specify a `struct GNUNET_TIME_Relative`
225 * A pointer to this function should be passed as part of the 261 * (using human-readable "fancy" time).
226 * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
227 * of this type. It should be followed by a pointer to a value of
228 * type `unsigned long long`.
229 * 262 *
230 * @param ctx command line processing context 263 * @param shortName short name of the option
231 * @param scls additional closure (will point to the 'unsigned long long') 264 * @param name long name of the option
232 * @param option name of the option 265 * @param argumentHelp help text for the option argument
233 * @param value actual value of the option as a string. 266 * @param description long help text for the option
234 * @return #GNUNET_OK if parsing the value worked 267 * @param[out] val set to the time specified at the command line
235 */ 268 */
236int 269struct GNUNET_GETOPT_CommandLineOption
237GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 270GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
238 void *scls, const char *option, const char *value); 271 const char *name,
272 const char *argumentHelp,
273 const char *description,
274 struct GNUNET_TIME_Relative *val);
239 275
240 276
241/** 277/**
242 * Set an option of type 'struct GNUNET_TIME_Relative' from the command line. 278 * Increment @a val each time the option flag is given by one.
243 * A pointer to this function should be passed as part of the
244 * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
245 * of this type. It should be followed by a pointer to a value of
246 * type `struct GNUNET_TIME_Relative`.
247 * 279 *
248 * @param ctx command line processing context 280 * @param shortName short name of the option
249 * @param scls additional closure (will point to the 'struct GNUNET_TIME_Relative') 281 * @param name long name of the option
250 * @param option name of the option 282 * @param argumentHelp help text for the option argument
251 * @param value actual value of the option as a string. 283 * @param description long help text for the option
252 * @return #GNUNET_OK if parsing the value worked 284 * @param[out] val set to 1 if the option is present
253 */ 285 */
254int 286struct GNUNET_GETOPT_CommandLineOption
255GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 287GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
256 void *scls, const char *option, const char *value); 288 const char *name,
289 const char *description,
290 unsigned int *val);
257 291
258 292
259/** 293/**
260 * Set an option of type 'unsigned int' from the command line. 294 * Define the '-L' log level option. Note that we do not check
261 * A pointer to this function should be passed as part of the 295 * that the log level is valid here.
262 * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
263 * of this type. It should be followed by a pointer to a value of
264 * type `unsigned int`.
265 * 296 *
266 * @param ctx command line processing context 297 * @param[out] level set to the log level
267 * @param scls additional closure (will point to the 'unsigned int')
268 * @param option name of the option
269 * @param value actual value of the option as a string.
270 * @return #GNUNET_OK if parsing the value worked
271 */ 298 */
272int 299struct GNUNET_GETOPT_CommandLineOption
273GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 300GNUNET_GETOPT_OPTION_LOGLEVEL (char **level);
274 void *scls, const char *option, const char *value);
275 301
276 302
277/** 303/**
278 * Set an option of type 'int' from the command line to 1 if the 304 * Define the '-V' verbosity option. Using the option more
279 * given option is present. 305 * than once increments @a level each time.
280 * A pointer to this function should be passed as part of the
281 * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
282 * of this type. It should be followed by a pointer to a value of
283 * type `int`.
284 * 306 *
285 * @param ctx command line processing context 307 * @param[out] level set to the verbosity level
286 * @param scls additional closure (will point to the `int`)
287 * @param option name of the option
288 * @param value not used (NULL)
289 * @return #GNUNET_OK (always)
290 */ 308 */
291int 309struct GNUNET_GETOPT_CommandLineOption
292GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 310GNUNET_GETOPT_OPTION_VERBOSE (int *level);
293 void *scls, const char *option, const char *value);
294 311
295 312
296/** 313/**
297 * Set an option of type 'char *' from the command line. 314 * Allow user to specify log file name (-l option)
298 * A pointer to this function should be passed as part of the
299 * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
300 * of this type. It should be followed by a pointer to a value of
301 * type `char *`, which will be allocated with the requested string.
302 * 315 *
303 * @param ctx command line processing context 316 * @param[out] logfn set to the name of the logfile
304 * @param scls additional closure (will point to the `char *`,
305 * which will be allocated)
306 * @param option name of the option
307 * @param value actual value of the option (a string)
308 * @return #GNUNET_OK (always)
309 */ 317 */
310int 318struct GNUNET_GETOPT_CommandLineOption
311GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 319GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
312 void *scls, const char *option, const char *value);
313 320
314 321
315/** 322/**
316 * Set an option of type 'char *' from the command line doing fs expansion. 323 * Allow user to specify configuration file name (-c option)
317 * A pointer to this function should be passed as part of the
318 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
319 * of this type. It should be followed by a pointer to a value of
320 * type 'char *', which will be allocated with the requested string.
321 * 324 *
322 * @param ctx command line processing context 325 * @param[out] fn set to the name of the configuration file
323 * @param scls additional closure (will point to the 'char *',
324 * which will be allocated)
325 * @param option name of the option
326 * @param value actual value of the option (a string)
327 * @return #GNUNET_OK (always)
328 */ 326 */
329int 327struct GNUNET_GETOPT_CommandLineOption
330GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 328GNUNET_GETOPT_OPTION_CFG_FILE (char **fn);
331 void *scls, const char *option, const char *value); 329
332 330
333/** 331/**
334 * Set an option of type 'unsigned int' from the command line. Each 332 * Marker for the end of the list of options.
335 * time the option flag is given, the value is incremented by one.
336 * A pointer to this function should be passed as part of the
337 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
338 * of this type. It should be followed by a pointer to a value of
339 * type 'int'.
340 *
341 * @param ctx command line processing context
342 * @param scls additional closure (will point to the 'int')
343 * @param option name of the option
344 * @param value not used (NULL)
345 * @return #GNUNET_OK (always)
346 */ 333 */
347int 334#define GNUNET_GETOPT_OPTION_END \
348GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext 335 { '\0', NULL, NULL, NULL, 0, NULL, NULL }
349 *ctx, void *scls, const char *option,
350 const char *value);
351
352 336
353/* *************** internal prototypes - use macros above! ************* */
354 337
355/** 338/**
356 * Print out details on command line options (implements --help). 339 * Parse the command line.
357 * 340 *
358 * @param ctx command line processing context 341 * @param binaryOptions Name of application with option summary
359 * @param scls additional closure (points to about text) 342 * @param allOptions defined options and handlers
360 * @param option name of the option 343 * @param argc number of arguments in @a argv
361 * @param value not used (NULL) 344 * @param argv actual arguments
362 * @return #GNUNET_NO (do not continue, not an error) 345 * @return index into argv with first non-option
346 * argument, or #GNUNET_SYSERR on error
363 */ 347 */
364int 348int
365GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext 349GNUNET_GETOPT_run (const char *binaryOptions,
366 *ctx, void *scls, const char *option, 350 const struct GNUNET_GETOPT_CommandLineOption *allOptions,
367 const char *value); 351 unsigned int argc,
352 char *const *argv);
368 353
369/**
370 * Print out program version (implements --version).
371 *
372 * @param ctx command line processing context
373 * @param scls additional closure (points to version string)
374 * @param option name of the option
375 * @param value not used (NULL)
376 * @return #GNUNET_NO (do not continue, not an error)
377 */
378int
379GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext
380 *ctx, void *scls, const char *option,
381 const char *value);
382 354
383#if 0 /* keep Emacsens' auto-indent happy */ 355#if 0 /* keep Emacsens' auto-indent happy */
384{ 356{
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 4d7104503..234f5371f 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -38,11 +38,11 @@
38 * @param value not used (NULL) 38 * @param value not used (NULL)
39 * @return #GNUNET_NO (do not continue, not an error) 39 * @return #GNUNET_NO (do not continue, not an error)
40 */ 40 */
41int 41static int
42GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 42print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
43 void *scls, 43 void *scls,
44 const char *option, 44 const char *option,
45 const char *value) 45 const char *value)
46{ 46{
47 const char *version = scls; 47 const char *version = scls;
48 48
@@ -54,6 +54,26 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext *
54 54
55 55
56/** 56/**
57 * Define the option to print the version of
58 * the application (-v option)
59 *
60 * @param version string with the version number
61 */
62struct GNUNET_GETOPT_CommandLineOption
63GNUNET_GETOPT_OPTION_VERSION (const char *version)
64{
65 struct GNUNET_GETOPT_CommandLineOption clo = {
66 .shortName = 'v',
67 .name = "version",
68 .description = gettext_noop("print the version number"),
69 .processor = &print_version,
70 .scls = (void *) version
71 };
72 return clo;
73}
74
75
76/**
57 * At what offset does the help text start? 77 * At what offset does the help text start?
58 */ 78 */
59#define BORDER 29 79#define BORDER 29
@@ -67,11 +87,11 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext *
67 * @param value not used (NULL) 87 * @param value not used (NULL)
68 * @return #GNUNET_NO (do not continue, not an error) 88 * @return #GNUNET_NO (do not continue, not an error)
69 */ 89 */
70int 90static int
71GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 91format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
72 void *scls, 92 void *scls,
73 const char *option, 93 const char *option,
74 const char *value) 94 const char *value)
75{ 95{
76 const char *about = scls; 96 const char *about = scls;
77 size_t slen; 97 size_t slen;
@@ -165,6 +185,27 @@ OUTER:
165 185
166 186
167/** 187/**
188 * Defining the option to print the command line
189 * help text (-h option).
190 *
191 * @param about string with brief description of the application
192 */
193struct GNUNET_GETOPT_CommandLineOption
194GNUNET_GETOPT_OPTION_HELP (const char *about)
195{
196 struct GNUNET_GETOPT_CommandLineOption clo = {
197 .shortName = 'h',
198 .name = "help",
199 .description = gettext_noop("print this help"),
200 .processor = format_help,
201 .scls = (void *) about
202 };
203
204 return clo;
205}
206
207
208/**
168 * Set an option of type 'unsigned int' from the command line. Each 209 * Set an option of type 'unsigned int' from the command line. Each
169 * time the option flag is given, the value is incremented by one. 210 * time the option flag is given, the value is incremented by one.
170 * A pointer to this function should be passed as part of the 211 * A pointer to this function should be passed as part of the
@@ -173,17 +214,18 @@ OUTER:
173 * type 'int'. 214 * type 'int'.
174 * 215 *
175 * @param ctx command line processing context 216 * @param ctx command line processing context
176 * @param scls additional closure (will point to the 'int') 217 * @param scls additional closure (will point to the 'unsigned int')
177 * @param option name of the option 218 * @param option name of the option
178 * @param value not used (NULL) 219 * @param value not used (NULL)
179 * @return #GNUNET_OK 220 * @return #GNUNET_OK
180 */ 221 */
181int 222static int
182GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext 223increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
183 *ctx, void *scls, const char *option, 224 void *scls,
184 const char *value) 225 const char *option,
226 const char *value)
185{ 227{
186 int *val = scls; 228 unsigned int *val = scls;
187 229
188 (*val)++; 230 (*val)++;
189 return GNUNET_OK; 231 return GNUNET_OK;
@@ -191,6 +233,54 @@ GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext
191 233
192 234
193/** 235/**
236 * Increment @a val each time the option flag is given by one.
237 *
238 * @param shortName short name of the option
239 * @param name long name of the option
240 * @param argumentHelp help text for the option argument
241 * @param description long help text for the option
242 * @param[out] val increment by 1 each time the option is present
243 */
244struct GNUNET_GETOPT_CommandLineOption
245GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
246 const char *name,
247 const char *description,
248 unsigned int *val)
249{
250 struct GNUNET_GETOPT_CommandLineOption clo = {
251 .shortName = shortName,
252 .name = name,
253 .description = description,
254 .processor = &increment_value,
255 .scls = (void *) val
256 };
257
258 return clo;
259}
260
261
262/**
263 * Define the '-V' verbosity option. Using the option more
264 * than once increments @a level each time.
265 *
266 * @param[out] level set to the verbosity level
267 */
268struct GNUNET_GETOPT_CommandLineOption
269GNUNET_GETOPT_OPTION_VERBOSE (int *level)
270{
271 struct GNUNET_GETOPT_CommandLineOption clo = {
272 .shortName = 'V',
273 .name = "verbose",
274 .description = gettext_noop("be verbose"),
275 .processor = &increment_value,
276 .scls = (void *) level
277 };
278
279 return clo;
280}
281
282
283/**
194 * Set an option of type 'int' from the command line to 1 if the 284 * Set an option of type 'int' from the command line to 1 if the
195 * given option is present. 285 * given option is present.
196 * A pointer to this function should be passed as part of the 286 * A pointer to this function should be passed as part of the
@@ -204,9 +294,11 @@ GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext
204 * @param value not used (NULL) 294 * @param value not used (NULL)
205 * @return #GNUNET_OK 295 * @return #GNUNET_OK
206 */ 296 */
207int 297static int
208GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 298set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
209 void *scls, const char *option, const char *value) 299 void *scls,
300 const char *option,
301 const char *value)
210{ 302{
211 int *val = scls; 303 int *val = scls;
212 304
@@ -216,6 +308,34 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
216 308
217 309
218/** 310/**
311 * Allow user to specify a flag (which internally means setting
312 * an integer to 1/#GNUNET_YES/#GNUNET_OK.
313 *
314 * @param shortName short name of the option
315 * @param name long name of the option
316 * @param argumentHelp help text for the option argument
317 * @param description long help text for the option
318 * @param[out] val set to 1 if the option is present
319 */
320struct GNUNET_GETOPT_CommandLineOption
321GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
322 const char *name,
323 const char *description,
324 int *val)
325{
326 struct GNUNET_GETOPT_CommandLineOption clo = {
327 .shortName = shortName,
328 .name = name,
329 .description = description,
330 .processor = &set_one,
331 .scls = (void *) val
332 };
333
334 return clo;
335}
336
337
338/**
219 * Set an option of type 'char *' from the command line. 339 * Set an option of type 'char *' from the command line.
220 * A pointer to this function should be passed as part of the 340 * A pointer to this function should be passed as part of the
221 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options 341 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
@@ -229,9 +349,11 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
229 * @param value actual value of the option (a string) 349 * @param value actual value of the option (a string)
230 * @return #GNUNET_OK 350 * @return #GNUNET_OK
231 */ 351 */
232int 352static int
233GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 353set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
234 void *scls, const char *option, const char *value) 354 void *scls,
355 const char *option,
356 const char *value)
235{ 357{
236 char **val = scls; 358 char **val = scls;
237 359
@@ -242,18 +364,159 @@ GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
242} 364}
243 365
244 366
245int 367/**
246GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 368 * Allow user to specify a string.
247 void *scls, const char *option, const char *value) 369 *
370 * @param shortName short name of the option
371 * @param name long name of the option
372 * @param argumentHelp help text for the option argument
373 * @param description long help text for the option
374 * @param[out] str set to the string
375 */
376struct GNUNET_GETOPT_CommandLineOption
377GNUNET_GETOPT_OPTION_STRING (char shortName,
378 const char *name,
379 const char *argumentHelp,
380 const char *description,
381 char **str)
382{
383 struct GNUNET_GETOPT_CommandLineOption clo = {
384 .shortName = shortName,
385 .name = name,
386 .argumentHelp = argumentHelp,
387 .description = description,
388 .require_argument = 1,
389 .processor = &set_string,
390 .scls = (void *) str
391 };
392
393 return clo;
394}
395
396
397/**
398 * Define the '-L' log level option. Note that we do not check
399 * that the log level is valid here.
400 *
401 * @param[out] level set to the log level
402 */
403struct GNUNET_GETOPT_CommandLineOption
404GNUNET_GETOPT_OPTION_LOGLEVEL (char **level)
405{
406 struct GNUNET_GETOPT_CommandLineOption clo = {
407 .shortName = 'L',
408 .name = "log",
409 .argumentHelp = "LOGLEVEL",
410 .description = gettext_noop("configure logging to use LOGLEVEL"),
411 .require_argument = 1,
412 .processor = &set_string,
413 .scls = (void *) level
414 };
415
416 return clo;
417}
418
419
420/**
421 * Set an option of type 'char *' from the command line with
422 * filename expansion a la #GNUNET_STRINGS_filename_expand().
423 *
424 * @param ctx command line processing context
425 * @param scls additional closure (will point to the `char *`,
426 * which will be allocated)
427 * @param option name of the option
428 * @param value actual value of the option (a string)
429 * @return #GNUNET_OK
430 */
431static int
432set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
433 void *scls,
434 const char *option,
435 const char *value)
248{ 436{
249 char **val = scls; 437 char **val = scls;
250 438
251 GNUNET_assert (value != NULL); 439 GNUNET_assert (NULL != value);
252 GNUNET_free_non_null (*val); 440 GNUNET_free_non_null (*val);
253 *val = GNUNET_STRINGS_filename_expand (value); 441 *val = GNUNET_STRINGS_filename_expand (value);
254 return GNUNET_OK; 442 return GNUNET_OK;
255} 443}
256 444
445
446/**
447 * Allow user to specify a filename (automatically path expanded).
448 *
449 * @param shortName short name of the option
450 * @param name long name of the option
451 * @param argumentHelp help text for the option argument
452 * @param description long help text for the option
453 * @param[out] str set to the string
454 */
455struct GNUNET_GETOPT_CommandLineOption
456GNUNET_GETOPT_OPTION_FILENAME (char shortName,
457 const char *name,
458 const char *argumentHelp,
459 const char *description,
460 char **str)
461{
462 struct GNUNET_GETOPT_CommandLineOption clo = {
463 .shortName = shortName,
464 .name = name,
465 .argumentHelp = argumentHelp,
466 .description = description,
467 .require_argument = 1,
468 .processor = &set_filename,
469 .scls = (void *) str
470 };
471
472 return clo;
473}
474
475
476/**
477 * Allow user to specify log file name (-l option)
478 *
479 * @param[out] logfn set to the name of the logfile
480 */
481struct GNUNET_GETOPT_CommandLineOption
482GNUNET_GETOPT_OPTION_LOGFILE (char **logfn)
483{
484 struct GNUNET_GETOPT_CommandLineOption clo = {
485 .shortName = 'l',
486 .name = "logfile",
487 .argumentHelp = "FILENAME",
488 .description = gettext_noop ("configure logging to write logs to FILENAME"),
489 .require_argument = 1,
490 .processor = &set_filename,
491 .scls = (void *) logfn
492 };
493
494 return clo;
495}
496
497
498/**
499 * Allow user to specify configuration file name (-c option)
500 *
501 * @param[out] fn set to the name of the configuration file
502 */
503struct GNUNET_GETOPT_CommandLineOption
504GNUNET_GETOPT_OPTION_CFG_FILE (char **fn)
505{
506 struct GNUNET_GETOPT_CommandLineOption clo = {
507 .shortName = 'c',
508 .name = "config",
509 .argumentHelp = "FILENAME",
510 .description = gettext_noop("use configuration file FILENAME"),
511 .require_argument = 1,
512 .processor = &set_filename,
513 .scls = (void *) fn
514 };
515
516 return clo;
517}
518
519
257/** 520/**
258 * Set an option of type 'unsigned long long' from the command line. 521 * Set an option of type 'unsigned long long' from the command line.
259 * A pointer to this function should be passed as part of the 522 * A pointer to this function should be passed as part of the
@@ -267,15 +530,21 @@ GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ct
267 * @param value actual value of the option as a string. 530 * @param value actual value of the option as a string.
268 * @return #GNUNET_OK if parsing the value worked 531 * @return #GNUNET_OK if parsing the value worked
269 */ 532 */
270int 533static int
271GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 534set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
272 void *scls, const char *option, const char *value) 535 void *scls,
536 const char *option,
537 const char *value)
273{ 538{
274 unsigned long long *val = scls; 539 unsigned long long *val = scls;
275 540
276 if (1 != SSCANF (value, "%llu", val)) 541 if (1 != SSCANF (value,
542 "%llu",
543 val))
277 { 544 {
278 FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option); 545 FPRINTF (stderr,
546 _("You must pass a number to the `%s' option.\n"),
547 option);
279 return GNUNET_SYSERR; 548 return GNUNET_SYSERR;
280 } 549 }
281 return GNUNET_OK; 550 return GNUNET_OK;
@@ -283,6 +552,36 @@ GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
283 552
284 553
285/** 554/**
555 * Allow user to specify an `unsigned long long`
556 *
557 * @param shortName short name of the option
558 * @param name long name of the option
559 * @param argumentHelp help text for the option argument
560 * @param description long help text for the option
561 * @param[out] val set to the value specified at the command line
562 */
563struct GNUNET_GETOPT_CommandLineOption
564GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
565 const char *name,
566 const char *argumentHelp,
567 const char *description,
568 unsigned long long *val)
569{
570 struct GNUNET_GETOPT_CommandLineOption clo = {
571 .shortName = shortName,
572 .name = name,
573 .argumentHelp = argumentHelp,
574 .description = description,
575 .require_argument = 1,
576 .processor = &set_ulong,
577 .scls = (void *) val
578 };
579
580 return clo;
581}
582
583
584/**
286 * Set an option of type 'struct GNUNET_TIME_Relative' from the command line. 585 * Set an option of type 'struct GNUNET_TIME_Relative' from the command line.
287 * A pointer to this function should be passed as part of the 586 * A pointer to this function should be passed as part of the
288 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options 587 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
@@ -295,9 +594,11 @@ GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
295 * @param value actual value of the option as a string. 594 * @param value actual value of the option as a string.
296 * @return #GNUNET_OK if parsing the value worked 595 * @return #GNUNET_OK if parsing the value worked
297 */ 596 */
298int 597static int
299GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 598set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
300 void *scls, const char *option, const char *value) 599 void *scls,
600 const char *option,
601 const char *value)
301{ 602{
302 struct GNUNET_TIME_Relative *val = scls; 603 struct GNUNET_TIME_Relative *val = scls;
303 604
@@ -305,7 +606,9 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex
305 GNUNET_STRINGS_fancy_time_to_relative (value, 606 GNUNET_STRINGS_fancy_time_to_relative (value,
306 val)) 607 val))
307 { 608 {
308 FPRINTF (stderr, _("You must pass relative time to the `%s' option.\n"), option); 609 FPRINTF (stderr,
610 _("You must pass relative time to the `%s' option.\n"),
611 option);
309 return GNUNET_SYSERR; 612 return GNUNET_SYSERR;
310 } 613 }
311 return GNUNET_OK; 614 return GNUNET_OK;
@@ -313,6 +616,37 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex
313 616
314 617
315/** 618/**
619 * Allow user to specify a `struct GNUNET_TIME_Relative`
620 * (using human-readable "fancy" time).
621 *
622 * @param shortName short name of the option
623 * @param name long name of the option
624 * @param argumentHelp help text for the option argument
625 * @param description long help text for the option
626 * @param[out] val set to the time specified at the command line
627 */
628struct GNUNET_GETOPT_CommandLineOption
629GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
630 const char *name,
631 const char *argumentHelp,
632 const char *description,
633 struct GNUNET_TIME_Relative *val)
634{
635 struct GNUNET_GETOPT_CommandLineOption clo = {
636 .shortName = shortName,
637 .name = name,
638 .argumentHelp = argumentHelp,
639 .description = description,
640 .require_argument = 1,
641 .processor = &set_relative_time,
642 .scls = (void *) val
643 };
644
645 return clo;
646}
647
648
649/**
316 * Set an option of type 'unsigned int' from the command line. 650 * Set an option of type 'unsigned int' from the command line.
317 * A pointer to this function should be passed as part of the 651 * A pointer to this function should be passed as part of the
318 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options 652 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
@@ -325,19 +659,55 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex
325 * @param value actual value of the option as a string. 659 * @param value actual value of the option as a string.
326 * @return #GNUNET_OK if parsing the value worked 660 * @return #GNUNET_OK if parsing the value worked
327 */ 661 */
328int 662static int
329GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 663set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
330 void *scls, const char *option, const char *value) 664 void *scls,
665 const char *option,
666 const char *value)
331{ 667{
332 unsigned int *val = scls; 668 unsigned int *val = scls;
333 669
334 if (1 != SSCANF (value, "%u", val)) 670 if (1 != SSCANF (value,
671 "%u",
672 val))
335 { 673 {
336 FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option); 674 FPRINTF (stderr,
675 _("You must pass a number to the `%s' option.\n"),
676 option);
337 return GNUNET_SYSERR; 677 return GNUNET_SYSERR;
338 } 678 }
339 return GNUNET_OK; 679 return GNUNET_OK;
340} 680}
341 681
342 682
683/**
684 * Allow user to specify an unsigned integer.
685 *
686 * @param shortName short name of the option
687 * @param name long name of the option
688 * @param argumentHelp help text for the option argument
689 * @param description long help text for the option
690 * @param[out] val set to the value specified at the command line
691 */
692struct GNUNET_GETOPT_CommandLineOption
693GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
694 const char *name,
695 const char *argumentHelp,
696 const char *description,
697 unsigned int *val)
698{
699 struct GNUNET_GETOPT_CommandLineOption clo = {
700 .shortName = shortName,
701 .name = name,
702 .argumentHelp = argumentHelp,
703 .description = description,
704 .require_argument = 1,
705 .processor = &set_uint,
706 .scls = (void *) val
707 };
708
709 return clo;
710}
711
712
343/* end of getopt_helpers.c */ 713/* end of getopt_helpers.c */
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 7ec7162f1..2beb772a9 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -223,34 +223,48 @@ run (void *cls,
223int 223int
224main (int argc, char *const *argv) 224main (int argc, char *const *argv)
225{ 225{
226 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 226 struct GNUNET_GETOPT_CommandLineOption options[] = {
227 { 'f', "filename", NULL, 227 GNUNET_GETOPT_OPTION_SET_ONE ('f',
228 gettext_noop ("obtain option of value as a filename (with $-expansion)"), 228 "filename",
229 0, &GNUNET_GETOPT_set_one, &is_filename }, 229 gettext_noop ("obtain option of value as a filename (with $-expansion)"),
230 { 's', "section", "SECTION", 230 &is_filename),
231 gettext_noop ("name of the section to access"), 231 GNUNET_GETOPT_OPTION_STRING ('s',
232 1, &GNUNET_GETOPT_set_string, &section }, 232 "section",
233 { 'o', "option", "OPTION", 233 "SECTION",
234 gettext_noop ("name of the option to access"), 234 gettext_noop ("name of the section to access"),
235 1, &GNUNET_GETOPT_set_string, &option }, 235 &section),
236 { 'V', "value", "VALUE", 236 GNUNET_GETOPT_OPTION_STRING ('o',
237 gettext_noop ("value to set"), 237 "option",
238 1, &GNUNET_GETOPT_set_string, &value }, 238 "OPTION",
239 { 'S', "list-sections", NULL, 239 gettext_noop ("name of the option to access"),
240 gettext_noop ("print available configuration sections"), 240 &option),
241 0, &GNUNET_GETOPT_set_one, &list_sections }, 241 GNUNET_GETOPT_OPTION_STRING ('V',
242 { 'w', "rewrite", NULL, 242 "value",
243 gettext_noop ("write configuration file that only contains delta to defaults"), 243 "VALUE",
244 0, &GNUNET_GETOPT_set_one, &rewrite }, 244 gettext_noop ("value to set"),
245 &value),
246 GNUNET_GETOPT_OPTION_SET_ONE ('S',
247 "list-sections",
248 gettext_noop ("print available configuration sections"),
249 &list_sections),
250 GNUNET_GETOPT_OPTION_SET_ONE ('w',
251 "rewrite",
252 gettext_noop ("write configuration file that only contains delta to defaults"),
253 &rewrite),
245 GNUNET_GETOPT_OPTION_END 254 GNUNET_GETOPT_OPTION_END
246 }; 255 };
247 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 256 if (GNUNET_OK !=
257 GNUNET_STRINGS_get_utf8_args (argc, argv,
258 &argc, &argv))
248 return 2; 259 return 2;
249 260
250 ret = (GNUNET_OK == 261 ret = (GNUNET_OK ==
251 GNUNET_PROGRAM_run (argc, argv, "gnunet-config [OPTIONS]", 262 GNUNET_PROGRAM_run (argc,
263 argv,
264 "gnunet-config [OPTIONS]",
252 gettext_noop ("Manipulate GNUnet configuration files"), 265 gettext_noop ("Manipulate GNUnet configuration files"),
253 options, &run, NULL)) ? 0 : ret; 266 options,
267 &run, NULL)) ? 0 : ret;
254 GNUNET_free ((void*) argv); 268 GNUNET_free ((void*) argv);
255 return ret; 269 return ret;
256} 270}
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index ddfd9b1c3..732228b52 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -41,7 +41,7 @@ static int list_keys;
41/** 41/**
42 * Flag for listing public key. 42 * Flag for listing public key.
43 */ 43 */
44static int list_keys_count; 44static unsigned int list_keys_count;
45 45
46/** 46/**
47 * Flag for printing public key. 47 * Flag for printing public key.
@@ -406,36 +406,50 @@ run (void *cls, char *const *args, const char *cfgfile,
406 * @return 0 ok, 1 on error 406 * @return 0 ok, 1 on error
407 */ 407 */
408int 408int
409main (int argc, char *const *argv) 409main (int argc,
410 char *const *argv)
410{ 411{
411 list_keys_count = UINT32_MAX; 412 list_keys_count = UINT32_MAX;
412 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 413 struct GNUNET_GETOPT_CommandLineOption options[] = {
413 { 'i', "iterate", "FILE", 414 GNUNET_GETOPT_OPTION_SET_ONE ('i',
414 gettext_noop ("list keys included in a file (for testing)"), 415 "iterate",
415 0, &GNUNET_GETOPT_set_one, &list_keys }, 416 gettext_noop ("list keys included in a file (for testing)"),
416 { 'e', "end=", "COUNT", 417 &list_keys),
417 gettext_noop ("number of keys to list included in a file (for testing)"), 418 GNUNET_GETOPT_OPTION_SET_UINT ('e',
418 1, &GNUNET_GETOPT_set_uint, &list_keys_count }, 419 "end=",
419 { 'g', "generate-keys", "COUNT", 420 "COUNT",
420 gettext_noop ("create COUNT public-private key pairs (for testing)"), 421 gettext_noop ("number of keys to list included in a file (for testing)"),
421 1, &GNUNET_GETOPT_set_uint, &make_keys }, 422 &list_keys_count),
422 { 'p', "print-public-key", NULL, 423 GNUNET_GETOPT_OPTION_SET_UINT ('g',
423 gettext_noop ("print the public key in ASCII format"), 424 "generate-keys",
424 0, &GNUNET_GETOPT_set_one, &print_public_key }, 425 "COUNT",
425 { 'E', "examples", NULL, 426 gettext_noop ("create COUNT public-private key pairs (for testing)"),
426 gettext_noop ("print examples of ECC operations (used for compatibility testing)"), 427 &make_keys),
427 0, &GNUNET_GETOPT_set_one, &print_examples_flag }, 428 GNUNET_GETOPT_OPTION_SET_ONE ('p',
429 "print-public-key",
430 gettext_noop ("print the public key in ASCII format"),
431 &print_public_key),
432 GNUNET_GETOPT_OPTION_SET_ONE ('E',
433 "examples",
434 gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
435 &print_examples_flag),
428 GNUNET_GETOPT_OPTION_END 436 GNUNET_GETOPT_OPTION_END
429 }; 437 };
430 int ret; 438 int ret;
431 439
432 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 440 if (GNUNET_OK !=
441 GNUNET_STRINGS_get_utf8_args (argc, argv,
442 &argc, &argv))
433 return 2; 443 return 2;
434 444
435 ret = (GNUNET_OK == 445 ret = (GNUNET_OK ==
436 GNUNET_PROGRAM_run (argc, argv, "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]", 446 GNUNET_PROGRAM_run (argc,
447 argv,
448 "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]",
437 gettext_noop ("Manipulate GNUnet private ECC key files"), 449 gettext_noop ("Manipulate GNUnet private ECC key files"),
438 options, &run, NULL)) ? 0 : 1; 450 options,
451 &run,
452 NULL)) ? 0 : 1;
439 GNUNET_free ((void*) argv); 453 GNUNET_free ((void*) argv);
440 return ret; 454 return ret;
441} 455}
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c
index e84a2332f..563cf9fce 100644
--- a/src/util/gnunet-resolver.c
+++ b/src/util/gnunet-resolver.c
@@ -144,10 +144,11 @@ run (void *cls, char *const *args, const char *cfgfile,
144int 144int
145main (int argc, char *const *argv) 145main (int argc, char *const *argv)
146{ 146{
147 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 147 struct GNUNET_GETOPT_CommandLineOption options[] = {
148 { 'r', "reverse", NULL, 148 GNUNET_GETOPT_OPTION_SET_ONE ('r',
149 gettext_noop ("perform a reverse lookup"), 149 "reverse",
150 0, &GNUNET_GETOPT_set_one, &reverse }, 150 gettext_noop ("perform a reverse lookup"),
151 &reverse),
151 GNUNET_GETOPT_OPTION_END 152 GNUNET_GETOPT_OPTION_END
152 }; 153 };
153 int ret; 154 int ret;
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index ab0cf92e0..7c73cfe1e 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -307,21 +307,30 @@ run (void *cls,
307 * @return 0 ok, 1 on error 307 * @return 0 ok, 1 on error
308 */ 308 */
309int 309int
310main (int argc, char *const *argv) 310main (int argc,
311 char *const *argv)
311{ 312{
312 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 313 struct GNUNET_GETOPT_CommandLineOption options[] = {
313 { 'b', "bits", "BITS", 314 GNUNET_GETOPT_OPTION_SET_ULONG ('b',
314 gettext_noop ("number of bits to require for the proof of work"), 315 "bits",
315 1, &GNUNET_GETOPT_set_ulong, &nse_work_required }, 316 "BITS",
316 { 'k', "keyfile", "FILE", 317 gettext_noop ("number of bits to require for the proof of work"),
317 gettext_noop ("file with private key, otherwise default is used"), 318 &nse_work_required),
318 1, &GNUNET_GETOPT_set_filename, &pkfn }, 319 GNUNET_GETOPT_OPTION_FILENAME ('k',
319 { 'o', "outfile", "FILE", 320 "keyfile",
320 gettext_noop ("file with proof of work, otherwise default is used"), 321 "FILE",
321 1, &GNUNET_GETOPT_set_filename, &pwfn }, 322 gettext_noop ("file with private key, otherwise default is used"),
322 { 't', "timeout", "TIME", 323 &pkfn),
323 gettext_noop ("time to wait between calculations"), 324 GNUNET_GETOPT_OPTION_FILENAME ('o',
324 1, &GNUNET_GETOPT_set_relative_time, &proof_find_delay }, 325 "outfile",
326 "FILE",
327 gettext_noop ("file with proof of work, otherwise default is used"),
328 &pwfn),
329 GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t',
330 "timeout",
331 "TIME",
332 gettext_noop ("time to wait between calculations"),
333 &proof_find_delay),
325 GNUNET_GETOPT_OPTION_END 334 GNUNET_GETOPT_OPTION_END
326 }; 335 };
327 int ret; 336 int ret;
@@ -334,7 +343,9 @@ main (int argc, char *const *argv)
334 GNUNET_PROGRAM_run (argc, argv, 343 GNUNET_PROGRAM_run (argc, argv,
335 "gnunet-scrypt [OPTIONS] prooffile", 344 "gnunet-scrypt [OPTIONS] prooffile",
336 gettext_noop ("Manipulate GNUnet proof of work files"), 345 gettext_noop ("Manipulate GNUnet proof of work files"),
337 options, &run, NULL)) ? 0 : 1; 346 options,
347 &run,
348 NULL)) ? 0 : 1;
338 GNUNET_free ((void*) argv); 349 GNUNET_free ((void*) argv);
339 GNUNET_free_non_null (pwfn); 350 GNUNET_free_non_null (pwfn);
340 return ret; 351 return ret;
diff --git a/src/util/service.c b/src/util/service.c
index 496904fb1..d1dffa139 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1402,9 +1402,10 @@ GNUNET_SERVICE_run (int argc, char *const *argv,
1402 1402
1403 struct GNUNET_GETOPT_CommandLineOption service_options[] = { 1403 struct GNUNET_GETOPT_CommandLineOption service_options[] = {
1404 GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_fn), 1404 GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_fn),
1405 {'d', "daemonize", NULL, 1405 GNUNET_GETOPT_OPTION_SET_ONE ('d',
1406 gettext_noop ("do daemonize (detach from terminal)"), 0, 1406 "daemonize",
1407 GNUNET_GETOPT_set_one, &do_daemonize}, 1407 gettext_noop ("do daemonize (detach from terminal)"),
1408 &do_daemonize),
1408 GNUNET_GETOPT_OPTION_HELP (NULL), 1409 GNUNET_GETOPT_OPTION_HELP (NULL),
1409 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), 1410 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
1410 GNUNET_GETOPT_OPTION_LOGFILE (&logfile), 1411 GNUNET_GETOPT_OPTION_LOGFILE (&logfile),
diff --git a/src/util/service_new.c b/src/util/service_new.c
index 9c0ee539b..b4d03c17c 100644
--- a/src/util/service_new.c
+++ b/src/util/service_new.c
@@ -1723,9 +1723,10 @@ GNUNET_SERVICE_ruN_ (int argc,
1723 1723
1724 struct GNUNET_GETOPT_CommandLineOption service_options[] = { 1724 struct GNUNET_GETOPT_CommandLineOption service_options[] = {
1725 GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename), 1725 GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename),
1726 {'d', "daemonize", NULL, 1726 GNUNET_GETOPT_OPTION_SET_ONE ('d',
1727 gettext_noop ("do daemonize (detach from terminal)"), 0, 1727 "daemonize",
1728 GNUNET_GETOPT_set_one, &do_daemonize}, 1728 gettext_noop ("do daemonize (detach from terminal)"),
1729 &do_daemonize),
1729 GNUNET_GETOPT_OPTION_HELP (NULL), 1730 GNUNET_GETOPT_OPTION_HELP (NULL),
1730 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), 1731 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
1731 GNUNET_GETOPT_OPTION_LOGFILE (&logfile), 1732 GNUNET_GETOPT_OPTION_LOGFILE (&logfile),