diff options
Diffstat (limited to 'src/util/getopt_helpers.c')
-rw-r--r-- | src/util/getopt_helpers.c | 79 |
1 files changed, 49 insertions, 30 deletions
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index c3d0e4c7c..c836c9055 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c | |||
@@ -46,6 +46,8 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
46 | { | 46 | { |
47 | const char *version = scls; | 47 | const char *version = scls; |
48 | 48 | ||
49 | (void) option; | ||
50 | (void) value; | ||
49 | printf ("%s v%s\n", | 51 | printf ("%s v%s\n", |
50 | ctx->binaryName, | 52 | ctx->binaryName, |
51 | version); | 53 | version); |
@@ -104,6 +106,8 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
104 | const struct GNUNET_GETOPT_CommandLineOption *opt; | 106 | const struct GNUNET_GETOPT_CommandLineOption *opt; |
105 | const struct GNUNET_OS_ProjectData *pd; | 107 | const struct GNUNET_OS_ProjectData *pd; |
106 | 108 | ||
109 | (void) option; | ||
110 | (void) value; | ||
107 | if (NULL != about) | 111 | if (NULL != about) |
108 | { | 112 | { |
109 | printf ("%s\n%s\n", ctx->binaryOptions, gettext (about)); | 113 | printf ("%s\n%s\n", ctx->binaryOptions, gettext (about)); |
@@ -112,7 +116,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
112 | } | 116 | } |
113 | i = 0; | 117 | i = 0; |
114 | opt = ctx->allOptions; | 118 | opt = ctx->allOptions; |
115 | while (opt[i].description != NULL) | 119 | while (NULL != opt[i].description) |
116 | { | 120 | { |
117 | if (opt[i].shortName == '\0') | 121 | if (opt[i].shortName == '\0') |
118 | printf (" "); | 122 | printf (" "); |
@@ -120,7 +124,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
120 | printf (" -%c, ", opt[i].shortName); | 124 | printf (" -%c, ", opt[i].shortName); |
121 | printf ("--%s", opt[i].name); | 125 | printf ("--%s", opt[i].name); |
122 | slen = 8 + strlen (opt[i].name); | 126 | slen = 8 + strlen (opt[i].name); |
123 | if (opt[i].argumentHelp != NULL) | 127 | if (NULL != opt[i].argumentHelp) |
124 | { | 128 | { |
125 | printf ("=%s", opt[i].argumentHelp); | 129 | printf ("=%s", opt[i].argumentHelp); |
126 | slen += 1 + strlen (opt[i].argumentHelp); | 130 | slen += 1 + strlen (opt[i].argumentHelp); |
@@ -144,7 +148,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
144 | OUTER: | 148 | OUTER: |
145 | while (ml - p > 78 - slen) | 149 | while (ml - p > 78 - slen) |
146 | { | 150 | { |
147 | for (j = p + 78 - slen; j > p; j--) | 151 | for (j = p + 78 - slen; j > (int) p; j--) |
148 | { | 152 | { |
149 | if (isspace ((unsigned char) trans[j])) | 153 | if (isspace ((unsigned char) trans[j])) |
150 | { | 154 | { |
@@ -227,6 +231,9 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
227 | { | 231 | { |
228 | unsigned int *val = scls; | 232 | unsigned int *val = scls; |
229 | 233 | ||
234 | (void) ctx; | ||
235 | (void) option; | ||
236 | (void) value; | ||
230 | (*val)++; | 237 | (*val)++; |
231 | return GNUNET_OK; | 238 | return GNUNET_OK; |
232 | } | 239 | } |
@@ -243,9 +250,9 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
243 | */ | 250 | */ |
244 | struct GNUNET_GETOPT_CommandLineOption | 251 | struct GNUNET_GETOPT_CommandLineOption |
245 | GNUNET_GETOPT_option_increment_uint (char shortName, | 252 | GNUNET_GETOPT_option_increment_uint (char shortName, |
246 | const char *name, | 253 | const char *name, |
247 | const char *description, | 254 | const char *description, |
248 | unsigned int *val) | 255 | unsigned int *val) |
249 | { | 256 | { |
250 | struct GNUNET_GETOPT_CommandLineOption clo = { | 257 | struct GNUNET_GETOPT_CommandLineOption clo = { |
251 | .shortName = shortName, | 258 | .shortName = shortName, |
@@ -302,6 +309,9 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
302 | { | 309 | { |
303 | int *val = scls; | 310 | int *val = scls; |
304 | 311 | ||
312 | (void) ctx; | ||
313 | (void) option; | ||
314 | (void) value; | ||
305 | *val = 1; | 315 | *val = 1; |
306 | return GNUNET_OK; | 316 | return GNUNET_OK; |
307 | } | 317 | } |
@@ -319,9 +329,9 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
319 | */ | 329 | */ |
320 | struct GNUNET_GETOPT_CommandLineOption | 330 | struct GNUNET_GETOPT_CommandLineOption |
321 | GNUNET_GETOPT_option_flag (char shortName, | 331 | GNUNET_GETOPT_option_flag (char shortName, |
322 | const char *name, | 332 | const char *name, |
323 | const char *description, | 333 | const char *description, |
324 | int *val) | 334 | int *val) |
325 | { | 335 | { |
326 | struct GNUNET_GETOPT_CommandLineOption clo = { | 336 | struct GNUNET_GETOPT_CommandLineOption clo = { |
327 | .shortName = shortName, | 337 | .shortName = shortName, |
@@ -357,6 +367,8 @@ set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
357 | { | 367 | { |
358 | char **val = scls; | 368 | char **val = scls; |
359 | 369 | ||
370 | (void) ctx; | ||
371 | (void) option; | ||
360 | GNUNET_assert (NULL != value); | 372 | GNUNET_assert (NULL != value); |
361 | GNUNET_free_non_null (*val); | 373 | GNUNET_free_non_null (*val); |
362 | *val = GNUNET_strdup (value); | 374 | *val = GNUNET_strdup (value); |
@@ -436,6 +448,8 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
436 | { | 448 | { |
437 | char **val = scls; | 449 | char **val = scls; |
438 | 450 | ||
451 | (void) ctx; | ||
452 | (void) option; | ||
439 | GNUNET_assert (NULL != value); | 453 | GNUNET_assert (NULL != value); |
440 | GNUNET_free_non_null (*val); | 454 | GNUNET_free_non_null (*val); |
441 | *val = GNUNET_STRINGS_filename_expand (value); | 455 | *val = GNUNET_STRINGS_filename_expand (value); |
@@ -454,10 +468,10 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
454 | */ | 468 | */ |
455 | struct GNUNET_GETOPT_CommandLineOption | 469 | struct GNUNET_GETOPT_CommandLineOption |
456 | GNUNET_GETOPT_option_filename (char shortName, | 470 | GNUNET_GETOPT_option_filename (char shortName, |
457 | const char *name, | 471 | const char *name, |
458 | const char *argumentHelp, | 472 | const char *argumentHelp, |
459 | const char *description, | 473 | const char *description, |
460 | char **str) | 474 | char **str) |
461 | { | 475 | { |
462 | struct GNUNET_GETOPT_CommandLineOption clo = { | 476 | struct GNUNET_GETOPT_CommandLineOption clo = { |
463 | .shortName = shortName, | 477 | .shortName = shortName, |
@@ -538,6 +552,7 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
538 | { | 552 | { |
539 | unsigned long long *val = scls; | 553 | unsigned long long *val = scls; |
540 | 554 | ||
555 | (void) ctx; | ||
541 | if (1 != SSCANF (value, | 556 | if (1 != SSCANF (value, |
542 | "%llu", | 557 | "%llu", |
543 | val)) | 558 | val)) |
@@ -562,10 +577,10 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
562 | */ | 577 | */ |
563 | struct GNUNET_GETOPT_CommandLineOption | 578 | struct GNUNET_GETOPT_CommandLineOption |
564 | GNUNET_GETOPT_option_ulong (char shortName, | 579 | GNUNET_GETOPT_option_ulong (char shortName, |
565 | const char *name, | 580 | const char *name, |
566 | const char *argumentHelp, | 581 | const char *argumentHelp, |
567 | const char *description, | 582 | const char *description, |
568 | unsigned long long *val) | 583 | unsigned long long *val) |
569 | { | 584 | { |
570 | struct GNUNET_GETOPT_CommandLineOption clo = { | 585 | struct GNUNET_GETOPT_CommandLineOption clo = { |
571 | .shortName = shortName, | 586 | .shortName = shortName, |
@@ -601,7 +616,8 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
601 | const char *value) | 616 | const char *value) |
602 | { | 617 | { |
603 | struct GNUNET_TIME_Relative *val = scls; | 618 | struct GNUNET_TIME_Relative *val = scls; |
604 | 619 | ||
620 | (void) ctx; | ||
605 | if (GNUNET_OK != | 621 | if (GNUNET_OK != |
606 | GNUNET_STRINGS_fancy_time_to_relative (value, | 622 | GNUNET_STRINGS_fancy_time_to_relative (value, |
607 | val)) | 623 | val)) |
@@ -627,10 +643,10 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
627 | */ | 643 | */ |
628 | struct GNUNET_GETOPT_CommandLineOption | 644 | struct GNUNET_GETOPT_CommandLineOption |
629 | GNUNET_GETOPT_option_relative_time (char shortName, | 645 | GNUNET_GETOPT_option_relative_time (char shortName, |
630 | const char *name, | 646 | const char *name, |
631 | const char *argumentHelp, | 647 | const char *argumentHelp, |
632 | const char *description, | 648 | const char *description, |
633 | struct GNUNET_TIME_Relative *val) | 649 | struct GNUNET_TIME_Relative *val) |
634 | { | 650 | { |
635 | struct GNUNET_GETOPT_CommandLineOption clo = { | 651 | struct GNUNET_GETOPT_CommandLineOption clo = { |
636 | .shortName = shortName, | 652 | .shortName = shortName, |
@@ -667,6 +683,7 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
667 | { | 683 | { |
668 | struct GNUNET_TIME_Absolute *val = scls; | 684 | struct GNUNET_TIME_Absolute *val = scls; |
669 | 685 | ||
686 | (void) ctx; | ||
670 | if (GNUNET_OK != | 687 | if (GNUNET_OK != |
671 | GNUNET_STRINGS_fancy_time_to_absolute (value, | 688 | GNUNET_STRINGS_fancy_time_to_absolute (value, |
672 | val)) | 689 | val)) |
@@ -692,10 +709,10 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
692 | */ | 709 | */ |
693 | struct GNUNET_GETOPT_CommandLineOption | 710 | struct GNUNET_GETOPT_CommandLineOption |
694 | GNUNET_GETOPT_option_absolute_time (char shortName, | 711 | GNUNET_GETOPT_option_absolute_time (char shortName, |
695 | const char *name, | 712 | const char *name, |
696 | const char *argumentHelp, | 713 | const char *argumentHelp, |
697 | const char *description, | 714 | const char *description, |
698 | struct GNUNET_TIME_Absolute *val) | 715 | struct GNUNET_TIME_Absolute *val) |
699 | { | 716 | { |
700 | struct GNUNET_GETOPT_CommandLineOption clo = { | 717 | struct GNUNET_GETOPT_CommandLineOption clo = { |
701 | .shortName = shortName, | 718 | .shortName = shortName, |
@@ -732,6 +749,7 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
732 | { | 749 | { |
733 | unsigned int *val = scls; | 750 | unsigned int *val = scls; |
734 | 751 | ||
752 | (void) ctx; | ||
735 | if (1 != SSCANF (value, | 753 | if (1 != SSCANF (value, |
736 | "%u", | 754 | "%u", |
737 | val)) | 755 | val)) |
@@ -756,10 +774,10 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
756 | */ | 774 | */ |
757 | struct GNUNET_GETOPT_CommandLineOption | 775 | struct GNUNET_GETOPT_CommandLineOption |
758 | GNUNET_GETOPT_option_uint (char shortName, | 776 | GNUNET_GETOPT_option_uint (char shortName, |
759 | const char *name, | 777 | const char *name, |
760 | const char *argumentHelp, | 778 | const char *argumentHelp, |
761 | const char *description, | 779 | const char *description, |
762 | unsigned int *val) | 780 | unsigned int *val) |
763 | { | 781 | { |
764 | struct GNUNET_GETOPT_CommandLineOption clo = { | 782 | struct GNUNET_GETOPT_CommandLineOption clo = { |
765 | .shortName = shortName, | 783 | .shortName = shortName, |
@@ -813,6 +831,7 @@ set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
813 | { | 831 | { |
814 | struct Base32Context *bc = scls; | 832 | struct Base32Context *bc = scls; |
815 | 833 | ||
834 | (void) ctx; | ||
816 | if (GNUNET_OK != | 835 | if (GNUNET_OK != |
817 | GNUNET_STRINGS_string_to_data (value, | 836 | GNUNET_STRINGS_string_to_data (value, |
818 | strlen (value), | 837 | strlen (value), |