aboutsummaryrefslogtreecommitdiff
path: root/src/util
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 /src/util
parentcd475225e4fd83fcc16b77ea1294c11428447209 (diff)
downloadgnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.tar.gz
gnunet-30eb0faa8d4894659cc90c76cc634148df86eab9.zip
getopt major style fix, remove macro-mania with nicer typed functions
Diffstat (limited to 'src/util')
-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
7 files changed, 520 insertions, 108 deletions
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),