aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-22 23:28:58 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-22 23:28:58 +0200
commit988ac7f121b646cba3ca44567f54b1315398505d (patch)
tree96a6e224c13bd6c692b4bf68eb0f97c632095c46
parentea20a69462912d46cf4f9dc47e6c7945c9da5f97 (diff)
downloadgnunet-988ac7f121b646cba3ca44567f54b1315398505d.tar.gz
gnunet-988ac7f121b646cba3ca44567f54b1315398505d.zip
finish #4623
-rw-r--r--src/arm/gnunet-arm.c21
-rw-r--r--src/cadet/gnunet-service-cadet.c1
-rw-r--r--src/include/gnunet_getopt_lib.h60
-rw-r--r--src/namestore/gnunet-namestore.c18
-rw-r--r--src/util/getopt.c200
-rw-r--r--src/util/getopt_helpers.c441
-rw-r--r--src/util/gnunet-config.c181
7 files changed, 462 insertions, 460 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 5a4acb31a..7d705733a 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -799,25 +799,26 @@ main (int argc, char *const *argv)
799 gettext_noop ("don't let gnunet-service-arm inherit standard error"), 799 gettext_noop ("don't let gnunet-service-arm inherit standard error"),
800 &no_stderr), 800 &no_stderr),
801 GNUNET_GETOPT_OPTION_END}; 801 GNUNET_GETOPT_OPTION_END};
802 int lret;
802 803
803 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 804 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
804 return 2; 805 return 2;
805 if (GNUNET_OK == 806 if (GNUNET_OK ==
806 GNUNET_PROGRAM_run ( 807 (lret = GNUNET_PROGRAM_run (
807 argc, 808 argc,
808 argv, 809 argv,
809 "gnunet-arm", 810 "gnunet-arm",
810 gettext_noop ( 811 gettext_noop (
811 "Control services and the Automated Restart Manager (ARM)"), 812 "Control services and the Automated Restart Manager (ARM)"),
812 options, 813 options,
813 &run, 814 &run,
814 NULL)) 815 NULL)))
815 { 816 {
816 GNUNET_free ((void *) argv); 817 GNUNET_free ((void *) argv);
817 return ret; 818 return ret;
818 } 819 }
819 GNUNET_free ((void *) argv); 820 GNUNET_free ((void *) argv);
820 return 1; 821 return lret;
821} 822}
822 823
823/* end of gnunet-arm.c */ 824/* end of gnunet-arm.c */
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index e29330f99..209f7d392 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -32,7 +32,6 @@
32 * - channel: logical link between two clients, on the same or different peers. 32 * - channel: logical link between two clients, on the same or different peers.
33 * have properties like reliability. 33 * have properties like reliability.
34 */ 34 */
35
36#include "platform.h" 35#include "platform.h"
37#include "gnunet_util_lib.h" 36#include "gnunet_util_lib.h"
38#include "cadet.h" 37#include "cadet.h"
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index 17e36d889..1e99c63d0 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -33,9 +33,8 @@
33#define GNUNET_GETOPT_LIB_H 33#define GNUNET_GETOPT_LIB_H
34 34
35#ifdef __cplusplus 35#ifdef __cplusplus
36extern "C" 36extern "C" {
37{ 37#if 0 /* keep Emacsens' auto-indent happy */
38#if 0 /* keep Emacsens' auto-indent happy */
39} 38}
40#endif 39#endif
41#endif 40#endif
@@ -77,7 +76,6 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
77 * Current argument. 76 * Current argument.
78 */ 77 */
79 unsigned int currentArgument; 78 unsigned int currentArgument;
80
81}; 79};
82 80
83 81
@@ -90,12 +88,11 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
90 * @param value argument, NULL if none was given 88 * @param value argument, NULL if none was given
91 * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort 89 * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort
92 */ 90 */
93typedef int 91typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (
94(*GNUNET_GETOPT_CommandLineOptionProcessor) (struct 92 struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
95 GNUNET_GETOPT_CommandLineProcessorContext *ctx, 93 void *scls,
96 void *scls, 94 const char *option,
97 const char *option, 95 const char *value);
98 const char *value);
99 96
100 97
101/** 98/**
@@ -149,13 +146,12 @@ struct GNUNET_GETOPT_CommandLineOption
149 * Function to call on @e scls to clean up after processing all 146 * Function to call on @e scls to clean up after processing all
150 * the arguments. Can be NULL. 147 * the arguments. Can be NULL.
151 */ 148 */
152 void (*cleaner)(void *cls); 149 void (*cleaner) (void *cls);
153 150
154 /** 151 /**
155 * Specific closure to pass to the processor. 152 * Specific closure to pass to the processor.
156 */ 153 */
157 void *scls; 154 void *scls;
158
159}; 155};
160 156
161 157
@@ -179,7 +175,6 @@ struct GNUNET_GETOPT_CommandLineOption
179GNUNET_GETOPT_option_version (const char *version); 175GNUNET_GETOPT_option_version (const char *version);
180 176
181 177
182
183/** 178/**
184 * Allow user to specify log file name (-l option) 179 * Allow user to specify log file name (-l option)
185 * 180 *
@@ -254,8 +249,17 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
254 * @param[out] val binary value decoded from Crockford Base32-encoded argument; 249 * @param[out] val binary value decoded from Crockford Base32-encoded argument;
255 * size is determined by type (sizeof (*val)). 250 * size is determined by type (sizeof (*val)).
256 */ 251 */
257#define GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \ 252#define GNUNET_GETOPT_option_base32_auto(shortName, \
258 GNUNET_GETOPT_option_base32_fixed_size(shortName,name,argumentHelp,description,val,sizeof(*val)) 253 name, \
254 argumentHelp, \
255 description, \
256 val) \
257 GNUNET_GETOPT_option_base32_fixed_size (shortName, \
258 name, \
259 argumentHelp, \
260 description, \
261 val, \
262 sizeof (*val))
259 263
260 264
261/** 265/**
@@ -302,10 +306,10 @@ GNUNET_GETOPT_option_uint (char shortName,
302 */ 306 */
303struct GNUNET_GETOPT_CommandLineOption 307struct GNUNET_GETOPT_CommandLineOption
304GNUNET_GETOPT_option_uint16 (char shortName, 308GNUNET_GETOPT_option_uint16 (char shortName,
305 const char *name, 309 const char *name,
306 const char *argumentHelp, 310 const char *argumentHelp,
307 const char *description, 311 const char *description,
308 uint16_t *val); 312 uint16_t *val);
309 313
310 314
311/** 315/**
@@ -426,10 +430,22 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
426 430
427 431
428/** 432/**
433 * Make the given option mutually exclusive with other options.
434 *
435 * @param opt option to modify
436 * @return @a opt with the exclusive flag set.
437 */
438struct GNUNET_GETOPT_CommandLineOption
439GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt);
440
441
442/**
429 * Marker for the end of the list of options. 443 * Marker for the end of the list of options.
430 */ 444 */
431#define GNUNET_GETOPT_OPTION_END \ 445#define GNUNET_GETOPT_OPTION_END \
432 { '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL } 446 { \
447 '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
448 }
433 449
434 450
435/** 451/**
@@ -449,7 +465,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
449 char *const *argv); 465 char *const *argv);
450 466
451 467
452#if 0 /* keep Emacsens' auto-indent happy */ 468#if 0 /* keep Emacsens' auto-indent happy */
453{ 469{
454#endif 470#endif
455#ifdef __cplusplus 471#ifdef __cplusplus
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 26b5a704b..5d292525e 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1647,6 +1647,7 @@ main (int argc, char *const *argv)
1647 "name of the ego controlling the zone"), 1647 "name of the ego controlling the zone"),
1648 &ego_name), 1648 &ego_name),
1649 GNUNET_GETOPT_OPTION_END}; 1649 GNUNET_GETOPT_OPTION_END};
1650 int lret;
1650 1651
1651 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1652 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1652 return 2; 1653 return 2;
@@ -1654,17 +1655,18 @@ main (int argc, char *const *argv)
1654 is_public = -1; 1655 is_public = -1;
1655 is_shadow = -1; 1656 is_shadow = -1;
1656 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL); 1657 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
1657 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, 1658 if (GNUNET_OK !=
1658 argv, 1659 (lret = GNUNET_PROGRAM_run (argc,
1659 "gnunet-namestore", 1660 argv,
1660 _ ("GNUnet zone manipulation tool"), 1661 "gnunet-namestore",
1661 options, 1662 _ ("GNUnet zone manipulation tool"),
1662 &run, 1663 options,
1663 NULL)) 1664 &run,
1665 NULL)))
1664 { 1666 {
1665 GNUNET_free ((void *) argv); 1667 GNUNET_free ((void *) argv);
1666 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); 1668 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1667 return 1; 1669 return lret;
1668 } 1670 }
1669 GNUNET_free ((void *) argv); 1671 GNUNET_free ((void *) argv);
1670 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); 1672 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 44f6dcda2..048f52ee0 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -47,14 +47,15 @@ Copyright (C) 2006, 2017 Christian Grothoff
47#endif 47#endif
48#endif 48#endif
49 49
50#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__) 50#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
51 51
52#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-getopt", syscall) 52#define LOG_STRERROR(kind, syscall) \
53 GNUNET_log_from_strerror (kind, "util-getopt", syscall)
53 54
54#if defined (WIN32) && !defined (__CYGWIN32__) 55#if defined(WIN32) && ! defined(__CYGWIN32__)
55/* It's not Unix, really. See? Capital letters. */ 56/* It's not Unix, really. See? Capital letters. */
56#include <windows.h> 57#include <windows.h>
57#define getpid() GetCurrentProcessId() 58#define getpid() GetCurrentProcessId ()
58#endif 59#endif
59 60
60#ifndef _ 61#ifndef _
@@ -62,9 +63,9 @@ Copyright (C) 2006, 2017 Christian Grothoff
62 When compiling libc, the _ macro is predefined. */ 63 When compiling libc, the _ macro is predefined. */
63#ifdef HAVE_LIBINTL_H 64#ifdef HAVE_LIBINTL_H
64#include <libintl.h> 65#include <libintl.h>
65#define _(msgid) gettext (msgid) 66#define _(msgid) gettext (msgid)
66#else 67#else
67#define _(msgid) (msgid) 68#define _(msgid) (msgid)
68#endif 69#endif
69#endif 70#endif
70 71
@@ -176,21 +177,18 @@ static char *nextchar;
176 of the value of `ordering'. In the case of RETURN_IN_ORDER, only 177 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
177 `--' can cause `getopt' to return -1 with `GNoptind' != ARGC. */ 178 `--' can cause `getopt' to return -1 with `GNoptind' != ARGC. */
178 179
179static enum 180static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
180{
181 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
182} ordering;
183 181
184/* Value of POSIXLY_CORRECT environment variable. */ 182/* Value of POSIXLY_CORRECT environment variable. */
185static char *posixly_correct; 183static char *posixly_correct;
186 184
187#ifdef __GNU_LIBRARY__ 185#ifdef __GNU_LIBRARY__
188/* We want to avoid inclusion of string.h with non-GNU libraries 186/* We want to avoid inclusion of string.h with non-GNU libraries
189 because there are many ways it can cause trouble. 187 because there are many ways it can cause trouble.
190 On some systems, it contains special magic macros that don't work 188 On some systems, it contains special magic macros that don't work
191 in GCC. */ 189 in GCC. */
192#include <string.h> 190#include <string.h>
193#define my_index strchr 191#define my_index strchr
194#else 192#else
195 193
196/* Avoid depending on library functions or files 194/* Avoid depending on library functions or files
@@ -200,8 +198,7 @@ char *
200getenv (); 198getenv ();
201 199
202static char * 200static char *
203my_index (const char *str, 201my_index (const char *str, int chr)
204 int chr)
205{ 202{
206 while (*str) 203 while (*str)
207 { 204 {
@@ -217,7 +214,7 @@ my_index (const char *str,
217#ifdef __GNUC__ 214#ifdef __GNUC__
218/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. 215/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
219 That was relevant to code that was here before. */ 216 That was relevant to code that was here before. */
220#if !defined (__STDC__) || !__STDC__ 217#if ! defined(__STDC__) || ! __STDC__
221/* gcc with -traditional declares the built-in strlen to return int, 218/* gcc with -traditional declares the built-in strlen to return int,
222 and has done so at least since version 2.4.5. -- rms. */ 219 and has done so at least since version 2.4.5. -- rms. */
223extern int 220extern int
@@ -247,7 +244,7 @@ static int last_nonopt;
247 `first_nonopt' and `last_nonopt' are relocated so that they describe 244 `first_nonopt' and `last_nonopt' are relocated so that they describe
248 the new indices of the non-options in ARGV after they are moved. */ 245 the new indices of the non-options in ARGV after they are moved. */
249 246
250#if defined (__STDC__) && __STDC__ 247#if defined(__STDC__) && __STDC__
251static void 248static void
252exchange (char **); 249exchange (char **);
253#endif 250#endif
@@ -311,14 +308,12 @@ exchange (char **argv)
311 308
312/* Initialize the internal data when the first call is made. */ 309/* Initialize the internal data when the first call is made. */
313 310
314#if defined (__STDC__) && __STDC__ 311#if defined(__STDC__) && __STDC__
315static const char * 312static const char *
316_getopt_initialize (int, char *const *, const char *); 313_getopt_initialize (int, char *const *, const char *);
317#endif 314#endif
318static const char * 315static const char *
319_getopt_initialize (int argc, 316_getopt_initialize (int argc, char *const *argv, const char *optstring)
320 char *const *argv,
321 const char *optstring)
322{ 317{
323 /* Start processing options with ARGV-element 1 (since ARGV-element 0 318 /* Start processing options with ARGV-element 1 (since ARGV-element 0
324 * is the program name); the sequence of previously skipped 319 * is the program name); the sequence of previously skipped
@@ -407,8 +402,11 @@ _getopt_initialize (int argc,
407 long-named options. */ 402 long-named options. */
408 403
409static int 404static int
410GN_getopt_internal (int argc, char *const *argv, const char *optstring, 405GN_getopt_internal (int argc,
411 const struct GNoption *longopts, int *longind, 406 char *const *argv,
407 const char *optstring,
408 const struct GNoption *longopts,
409 int *longind,
412 int long_only) 410 int long_only)
413{ 411{
414 static int __getopt_initialized = 0; 412 static int __getopt_initialized = 0;
@@ -416,10 +414,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
416 414
417 GNoptarg = NULL; 415 GNoptarg = NULL;
418 416
419 if (GNoptind == 0 || !__getopt_initialized) 417 if (GNoptind == 0 || ! __getopt_initialized)
420 { 418 {
421 if (GNoptind == 0) 419 if (GNoptind == 0)
422 GNoptind = 1; /* Don't scan ARGV[0], the program name. */ 420 GNoptind = 1; /* Don't scan ARGV[0], the program name. */
423 optstring = _getopt_initialize (argc, argv, optstring); 421 optstring = _getopt_initialize (argc, argv, optstring);
424 __getopt_initialized = 1; 422 __getopt_initialized = 1;
425 } 423 }
@@ -463,7 +461,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
463 * Skip it like a null option, 461 * Skip it like a null option,
464 * then exchange with previous non-options as if it were an option, 462 * then exchange with previous non-options as if it were an option,
465 * then skip everything else like a non-option. */ 463 * then skip everything else like a non-option. */
466 if (GNoptind != argc && !strcmp (argv[GNoptind], "--")) 464 if (GNoptind != argc && ! strcmp (argv[GNoptind], "--"))
467 { 465 {
468 GNoptind++; 466 GNoptind++;
469 467
@@ -503,7 +501,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
503 * Skip the initial punctuation. */ 501 * Skip the initial punctuation. */
504 502
505 nextchar = 503 nextchar =
506 (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-')); 504 (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));
507 } 505 }
508 506
509 /* Decode the current option-ARGV-element. */ 507 /* Decode the current option-ARGV-element. */
@@ -524,7 +522,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
524 if (longopts != NULL && 522 if (longopts != NULL &&
525 (argv[GNoptind][1] == '-' || 523 (argv[GNoptind][1] == '-' ||
526 (long_only && 524 (long_only &&
527 (argv[GNoptind][2] || !my_index (optstring, argv[GNoptind][1]))))) 525 (argv[GNoptind][2] || ! my_index (optstring, argv[GNoptind][1])))))
528 { 526 {
529 char *nameend; 527 char *nameend;
530 const struct GNoption *p; 528 const struct GNoption *p;
@@ -535,12 +533,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
535 int option_index; 533 int option_index;
536 534
537 for (nameend = nextchar; *nameend && *nameend != '='; nameend++) 535 for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
538 /* Do nothing. */ ; 536 /* Do nothing. */;
539 537
540 /* Test all long options for either exact match 538 /* Test all long options for either exact match
541 * or abbreviated matches. */ 539 * or abbreviated matches. */
542 for (p = longopts, option_index = 0; p->name; p++, option_index++) 540 for (p = longopts, option_index = 0; p->name; p++, option_index++)
543 if (!strncmp (p->name, nextchar, nameend - nextchar)) 541 if (! strncmp (p->name, nextchar, nameend - nextchar))
544 { 542 {
545 if ((unsigned int) (nameend - nextchar) == 543 if ((unsigned int) (nameend - nextchar) ==
546 (unsigned int) strlen (p->name)) 544 (unsigned int) strlen (p->name))
@@ -562,10 +560,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
562 ambig = 1; 560 ambig = 1;
563 } 561 }
564 562
565 if (ambig && !exact) 563 if (ambig && ! exact)
566 { 564 {
567 if (GNopterr) 565 if (GNopterr)
568 FPRINTF (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], 566 FPRINTF (stderr,
567 _ ("%s: option `%s' is ambiguous\n"),
568 argv[0],
569 argv[GNoptind]); 569 argv[GNoptind]);
570 nextchar += strlen (nextchar); 570 nextchar += strlen (nextchar);
571 GNoptind++; 571 GNoptind++;
@@ -589,13 +589,16 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
589 if (argv[GNoptind - 1][1] == '-') 589 if (argv[GNoptind - 1][1] == '-')
590 /* --option */ 590 /* --option */
591 FPRINTF (stderr, 591 FPRINTF (stderr,
592 _("%s: option `--%s' does not allow an argument\n"), 592 _ ("%s: option `--%s' does not allow an argument\n"),
593 argv[0], pfound->name); 593 argv[0],
594 pfound->name);
594 else 595 else
595 /* +option or -option */ 596 /* +option or -option */
596 FPRINTF (stderr, 597 FPRINTF (stderr,
597 _("%s: option `%c%s' does not allow an argument\n"), 598 _ ("%s: option `%c%s' does not allow an argument\n"),
598 argv[0], argv[GNoptind - 1][0], pfound->name); 599 argv[0],
600 argv[GNoptind - 1][0],
601 pfound->name);
599 } 602 }
600 nextchar += strlen (nextchar); 603 nextchar += strlen (nextchar);
601 return '?'; 604 return '?';
@@ -611,8 +614,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
611 { 614 {
612 if (GNopterr) 615 if (GNopterr)
613 { 616 {
614 FPRINTF (stderr, _("%s: option `%s' requires an argument\n"), 617 FPRINTF (stderr,
615 argv[0], argv[GNoptind - 1]); 618 _ ("%s: option `%s' requires an argument\n"),
619 argv[0],
620 argv[GNoptind - 1]);
616 } 621 }
617 nextchar += strlen (nextchar); 622 nextchar += strlen (nextchar);
618 return (optstring[0] == ':') ? ':' : '?'; 623 return (optstring[0] == ':') ? ':' : '?';
@@ -633,19 +638,24 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
633 * or the option starts with '--' or is not a valid short 638 * or the option starts with '--' or is not a valid short
634 * option, then it's an error. 639 * option, then it's an error.
635 * Otherwise interpret it as a short option. */ 640 * Otherwise interpret it as a short option. */
636 if (!long_only || argv[GNoptind][1] == '-' || 641 if (! long_only || argv[GNoptind][1] == '-' ||
637 my_index (optstring, *nextchar) == NULL) 642 my_index (optstring, *nextchar) == NULL)
638 { 643 {
639 if (GNopterr) 644 if (GNopterr)
640 { 645 {
641 if (argv[GNoptind][1] == '-') 646 if (argv[GNoptind][1] == '-')
642 /* --option */ 647 /* --option */
643 FPRINTF (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], 648 FPRINTF (stderr,
649 _ ("%s: unrecognized option `--%s'\n"),
650 argv[0],
644 nextchar); 651 nextchar);
645 else 652 else
646 /* +option or -option */ 653 /* +option or -option */
647 FPRINTF (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], 654 FPRINTF (stderr,
648 argv[GNoptind][0], nextchar); 655 _ ("%s: unrecognized option `%c%s'\n"),
656 argv[0],
657 argv[GNoptind][0],
658 nextchar);
649 } 659 }
650 nextchar = (char *) ""; 660 nextchar = (char *) "";
651 GNoptind++; 661 GNoptind++;
@@ -669,9 +679,9 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
669 { 679 {
670 if (posixly_correct) 680 if (posixly_correct)
671 /* 1003.2 specifies the format of this message. */ 681 /* 1003.2 specifies the format of this message. */
672 FPRINTF (stderr, _("%s: illegal option -- %c\n"), argv[0], c); 682 FPRINTF (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
673 else 683 else
674 FPRINTF (stderr, _("%s: invalid option -- %c\n"), argv[0], c); 684 FPRINTF (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
675 } 685 }
676 return '?'; 686 return '?';
677 } 687 }
@@ -699,8 +709,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
699 if (GNopterr) 709 if (GNopterr)
700 { 710 {
701 /* 1003.2 specifies the format of this message. */ 711 /* 1003.2 specifies the format of this message. */
702 FPRINTF (stderr, _("%s: option requires an argument -- %c\n"), 712 FPRINTF (stderr,
703 argv[0], c); 713 _ ("%s: option requires an argument -- %c\n"),
714 argv[0],
715 c);
704 } 716 }
705 if (optstring[0] == ':') 717 if (optstring[0] == ':')
706 c = ':'; 718 c = ':';
@@ -718,13 +730,13 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
718 730
719 for (nextchar = nameend = GNoptarg; *nameend && *nameend != '='; 731 for (nextchar = nameend = GNoptarg; *nameend && *nameend != '=';
720 nameend++) 732 nameend++)
721 /* Do nothing. */ ; 733 /* Do nothing. */;
722 734
723 /* Test all long options for either exact match 735 /* Test all long options for either exact match
724 * or abbreviated matches. */ 736 * or abbreviated matches. */
725 if (longopts != NULL) 737 if (longopts != NULL)
726 for (p = longopts, option_index = 0; p->name; p++, option_index++) 738 for (p = longopts, option_index = 0; p->name; p++, option_index++)
727 if (!strncmp (p->name, nextchar, nameend - nextchar)) 739 if (! strncmp (p->name, nextchar, nameend - nextchar))
728 { 740 {
729 if ((unsigned int) (nameend - nextchar) == strlen (p->name)) 741 if ((unsigned int) (nameend - nextchar) == strlen (p->name))
730 { 742 {
@@ -744,10 +756,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
744 /* Second or later nonexact match found. */ 756 /* Second or later nonexact match found. */
745 ambig = 1; 757 ambig = 1;
746 } 758 }
747 if (ambig && !exact) 759 if (ambig && ! exact)
748 { 760 {
749 if (GNopterr) 761 if (GNopterr)
750 FPRINTF (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], 762 FPRINTF (stderr,
763 _ ("%s: option `-W %s' is ambiguous\n"),
764 argv[0],
751 argv[GNoptind]); 765 argv[GNoptind]);
752 nextchar += strlen (nextchar); 766 nextchar += strlen (nextchar);
753 GNoptind++; 767 GNoptind++;
@@ -765,7 +779,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
765 else 779 else
766 { 780 {
767 if (GNopterr) 781 if (GNopterr)
768 FPRINTF (stderr, _("%s: option `-W %s' does not allow an argument\n"), argv[0], pfound->name); 782 FPRINTF (stderr,
783 _ ("%s: option `-W %s' does not allow an argument\n"),
784 argv[0],
785 pfound->name);
769 786
770 nextchar += strlen (nextchar); 787 nextchar += strlen (nextchar);
771 return '?'; 788 return '?';
@@ -778,8 +795,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
778 else 795 else
779 { 796 {
780 if (GNopterr) 797 if (GNopterr)
781 FPRINTF (stderr, _("%s: option `%s' requires an argument\n"), 798 FPRINTF (stderr,
782 argv[0], argv[GNoptind - 1]); 799 _ ("%s: option `%s' requires an argument\n"),
800 argv[0],
801 argv[GNoptind - 1]);
783 nextchar += strlen (nextchar); 802 nextchar += strlen (nextchar);
784 return optstring[0] == ':' ? ':' : '?'; 803 return optstring[0] == ':' ? ':' : '?';
785 } 804 }
@@ -795,7 +814,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
795 return pfound->val; 814 return pfound->val;
796 } 815 }
797 nextchar = NULL; 816 nextchar = NULL;
798 return 'W'; /* Let the application handle it. */ 817 return 'W'; /* Let the application handle it. */
799 } 818 }
800 if (temp[1] == ':') 819 if (temp[1] == ':')
801 { 820 {
@@ -826,8 +845,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
826 if (GNopterr) 845 if (GNopterr)
827 { 846 {
828 /* 1003.2 specifies the format of this message. */ 847 /* 1003.2 specifies the format of this message. */
829 FPRINTF (stderr, _("%s: option requires an argument -- %c\n"), 848 FPRINTF (stderr,
830 argv[0], c); 849 _ ("%s: option requires an argument -- %c\n"),
850 argv[0],
851 c);
831 } 852 }
832 if (optstring[0] == ':') 853 if (optstring[0] == ':')
833 c = ':'; 854 c = ':';
@@ -880,8 +901,9 @@ GNUNET_GETOPT_run (const char *binaryOptions,
880 char *shorts; 901 char *shorts;
881 int spos; 902 int spos;
882 int cont; 903 int cont;
883 int c;
884 uint8_t *seen; 904 uint8_t *seen;
905 unsigned int optmatch = 0;
906 const char *have_exclusive = NULL;
885 907
886 GNUNET_assert (argc > 0); 908 GNUNET_assert (argc > 0);
887 GNoptind = 0; 909 GNoptind = 0;
@@ -890,12 +912,13 @@ GNUNET_GETOPT_run (const char *binaryOptions,
890 clpc.allOptions = allOptions; 912 clpc.allOptions = allOptions;
891 clpc.argv = argv; 913 clpc.argv = argv;
892 clpc.argc = argc; 914 clpc.argc = argc;
893 for (count = 0; NULL != allOptions[count].name; count++) ; 915 for (count = 0; NULL != allOptions[count].name; count++)
916 ;
894 917
895 long_options = GNUNET_new_array (count + 1, 918 /* transform our option representation into the format
896 struct GNoption); 919 used by the GNU getopt copylib */
897 seen = GNUNET_new_array (count, 920 long_options = GNUNET_new_array (count + 1, struct GNoption);
898 uint8_t); 921 seen = GNUNET_new_array (count, uint8_t);
899 shorts = GNUNET_malloc (count * 2 + 1); 922 shorts = GNUNET_malloc (count * 2 + 1);
900 spos = 0; 923 spos = 0;
901 for (unsigned i = 0; i < count; i++) 924 for (unsigned i = 0; i < count; i++)
@@ -916,59 +939,64 @@ GNUNET_GETOPT_run (const char *binaryOptions,
916 cont = GNUNET_OK; 939 cont = GNUNET_OK;
917 940
918 /* main getopt loop */ 941 /* main getopt loop */
919 while (GNUNET_OK == cont) 942 while (1)
920 { 943 {
921 int option_index = 0; 944 int option_index = 0;
922 unsigned int i; 945 unsigned int i;
946 int c;
923 947
924 c = GNgetopt_long (argc, argv, 948 c = GNgetopt_long (argc, argv, shorts, long_options, &option_index);
925 shorts,
926 long_options,
927 &option_index);
928 if (c == GNUNET_SYSERR) 949 if (c == GNUNET_SYSERR)
929 break; /* No more flags to process */ 950 break; /* No more flags to process */
930 951
952 /* Check which of our program's options was given by the user */
931 for (i = 0; i < count; i++) 953 for (i = 0; i < count; i++)
932 { 954 {
933 clpc.currentArgument = GNoptind - 1; 955 clpc.currentArgument = GNoptind - 1;
934 if ((char) c == allOptions[i].shortName) 956 if ((char) c == allOptions[i].shortName)
935 { 957 {
936 cont = allOptions[i].processor (&clpc, 958 optmatch++;
937 allOptions[i].scls, 959 if (allOptions[i].option_exclusive)
938 allOptions[i].name, 960 have_exclusive = allOptions[i].name;
939 GNoptarg); 961 if (GNUNET_OK == cont)
962 {
963 /* parse the option using the option-specific processor */
964 cont = allOptions[i].processor (&clpc,
965 allOptions[i].scls,
966 allOptions[i].name,
967 GNoptarg);
968 }
940 seen[i] = 1; 969 seen[i] = 1;
941 break; 970 break;
942 } 971 }
943 } 972 }
944 if (i == count) 973 if (i == count)
945 { 974 {
946 FPRINTF (stderr, 975 FPRINTF (stderr, _ ("Use %s to get a list of options.\n"), "--help");
947 _("Use %s to get a list of options.\n"),
948 "--help");
949 cont = GNUNET_SYSERR; 976 cont = GNUNET_SYSERR;
950 } 977 }
951 } 978 }
952 GNUNET_free (shorts); 979 GNUNET_free (shorts);
953 GNUNET_free (long_options); 980 GNUNET_free (long_options);
954 981
982 /* check that if any option that was marked as exclusive
983 is the only option that was provided */
984 if ((NULL != have_exclusive) && (optmatch > 1))
985 {
986 FPRINTF (stderr,
987 _ ("Option `%s' can't be used with other options.\n"),
988 have_exclusive);
989 cont = GNUNET_SYSERR;
990 }
955 if (GNUNET_YES == cont) 991 if (GNUNET_YES == cont)
956 { 992 {
957 for (count = 0; NULL != allOptions[count].name; count++) 993 /* check that all mandatory options are present */
994 for (count = 0; NULL != allOptions[count].name; count++)
958 { 995 {
959 if (allOptions[count].option_exclusive) 996 if ((0 == seen[count]) && (allOptions[count].option_mandatory))
960 {
961 FPRINTF (stderr,
962 _("Option `%s' can't be used with other options.\n"),
963 allOptions[count].name);
964 cont = GNUNET_SYSERR;
965 }
966
967 if ( (0 == seen[count]) &&
968 (allOptions[count].option_mandatory) )
969 { 997 {
970 FPRINTF (stderr, 998 FPRINTF (stderr,
971 _("Missing mandatory option `%s'.\n"), 999 _ ("Missing mandatory option `%s'.\n"),
972 allOptions[count].name); 1000 allOptions[count].name);
973 cont = GNUNET_SYSERR; 1001 cont = GNUNET_SYSERR;
974 } 1002 }
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index d6ba85733..05856beee 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -26,7 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28 28
29#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__) 29#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
30 30
31 31
32/** 32/**
@@ -48,9 +48,7 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
48 48
49 (void) option; 49 (void) option;
50 (void) value; 50 (void) value;
51 printf ("%s v%s\n", 51 printf ("%s v%s\n", ctx->binaryName, version);
52 ctx->binaryName,
53 version);
54 return GNUNET_NO; 52 return GNUNET_NO;
55} 53}
56 54
@@ -64,14 +62,13 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
64struct GNUNET_GETOPT_CommandLineOption 62struct GNUNET_GETOPT_CommandLineOption
65GNUNET_GETOPT_option_version (const char *version) 63GNUNET_GETOPT_option_version (const char *version)
66{ 64{
67 struct GNUNET_GETOPT_CommandLineOption clo = { 65 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'v',
68 .shortName = 'v', 66 .name = "version",
69 .name = "version", 67 .description = gettext_noop (
70 .description = gettext_noop("print the version number"), 68 "print the version number"),
71 .option_exclusive = 1, 69 .option_exclusive = 1,
72 .processor = &print_version, 70 .processor = &print_version,
73 .scls = (void *) version 71 .scls = (void *) version};
74 };
75 return clo; 72 return clo;
76} 73}
77 74
@@ -111,10 +108,9 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
111 (void) value; 108 (void) value;
112 if (NULL != about) 109 if (NULL != about)
113 { 110 {
114 printf ("%s\n%s\n", 111 printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
115 ctx->binaryOptions, 112 printf (_ (
116 gettext (about)); 113 "Arguments mandatory for long options are also mandatory for short options.\n"));
117 printf (_("Arguments mandatory for long options are also mandatory for short options.\n"));
118 } 114 }
119 i = 0; 115 i = 0;
120 opt = ctx->allOptions; 116 opt = ctx->allOptions;
@@ -147,7 +143,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
147 trans = ""; 143 trans = "";
148 ml = strlen (trans); 144 ml = strlen (trans);
149 p = 0; 145 p = 0;
150OUTER: 146 OUTER:
151 while (ml - p > 78 - slen) 147 while (ml - p > 78 - slen)
152 { 148 {
153 for (j = p + 78 - slen; j > (int) p; j--) 149 for (j = p + 78 - slen; j > (int) p; j--)
@@ -199,13 +195,13 @@ OUTER:
199struct GNUNET_GETOPT_CommandLineOption 195struct GNUNET_GETOPT_CommandLineOption
200GNUNET_GETOPT_option_help (const char *about) 196GNUNET_GETOPT_option_help (const char *about)
201{ 197{
202 struct GNUNET_GETOPT_CommandLineOption clo = { 198 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'h',
203 .shortName = 'h', 199 .name = "help",
204 .name = "help", 200 .description = gettext_noop (
205 .description = gettext_noop("print this help"), 201 "print this help"),
206 .processor = format_help, 202 .option_exclusive = 1,
207 .scls = (void *) about 203 .processor = format_help,
208 }; 204 .scls = (void *) about};
209 205
210 return clo; 206 return clo;
211} 207}
@@ -252,17 +248,15 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
252 */ 248 */
253struct GNUNET_GETOPT_CommandLineOption 249struct GNUNET_GETOPT_CommandLineOption
254GNUNET_GETOPT_option_increment_uint (char shortName, 250GNUNET_GETOPT_option_increment_uint (char shortName,
255 const char *name, 251 const char *name,
256 const char *description, 252 const char *description,
257 unsigned int *val) 253 unsigned int *val)
258{ 254{
259 struct GNUNET_GETOPT_CommandLineOption clo = { 255 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
260 .shortName = shortName, 256 .name = name,
261 .name = name, 257 .description = description,
262 .description = description, 258 .processor = &increment_value,
263 .processor = &increment_value, 259 .scls = (void *) val};
264 .scls = (void *) val
265 };
266 260
267 return clo; 261 return clo;
268} 262}
@@ -277,13 +271,12 @@ GNUNET_GETOPT_option_increment_uint (char shortName,
277struct GNUNET_GETOPT_CommandLineOption 271struct GNUNET_GETOPT_CommandLineOption
278GNUNET_GETOPT_option_verbose (unsigned int *level) 272GNUNET_GETOPT_option_verbose (unsigned int *level)
279{ 273{
280 struct GNUNET_GETOPT_CommandLineOption clo = { 274 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'V',
281 .shortName = 'V', 275 .name = "verbose",
282 .name = "verbose", 276 .description =
283 .description = gettext_noop("be verbose"), 277 gettext_noop ("be verbose"),
284 .processor = &increment_value, 278 .processor = &increment_value,
285 .scls = (void *) level 279 .scls = (void *) level};
286 };
287 280
288 return clo; 281 return clo;
289} 282}
@@ -331,17 +324,15 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
331 */ 324 */
332struct GNUNET_GETOPT_CommandLineOption 325struct GNUNET_GETOPT_CommandLineOption
333GNUNET_GETOPT_option_flag (char shortName, 326GNUNET_GETOPT_option_flag (char shortName,
334 const char *name, 327 const char *name,
335 const char *description, 328 const char *description,
336 int *val) 329 int *val)
337{ 330{
338 struct GNUNET_GETOPT_CommandLineOption clo = { 331 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
339 .shortName = shortName, 332 .name = name,
340 .name = name, 333 .description = description,
341 .description = description, 334 .processor = &set_one,
342 .processor = &set_one, 335 .scls = (void *) val};
343 .scls = (void *) val
344 };
345 336
346 return clo; 337 return clo;
347} 338}
@@ -394,15 +385,13 @@ GNUNET_GETOPT_option_string (char shortName,
394 const char *description, 385 const char *description,
395 char **str) 386 char **str)
396{ 387{
397 struct GNUNET_GETOPT_CommandLineOption clo = { 388 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
398 .shortName = shortName, 389 .name = name,
399 .name = name, 390 .argumentHelp = argumentHelp,
400 .argumentHelp = argumentHelp, 391 .description = description,
401 .description = description, 392 .require_argument = 1,
402 .require_argument = 1, 393 .processor = &set_string,
403 .processor = &set_string, 394 .scls = (void *) str};
404 .scls = (void *) str
405 };
406 395
407 return clo; 396 return clo;
408} 397}
@@ -417,15 +406,14 @@ GNUNET_GETOPT_option_string (char shortName,
417struct GNUNET_GETOPT_CommandLineOption 406struct GNUNET_GETOPT_CommandLineOption
418GNUNET_GETOPT_option_loglevel (char **level) 407GNUNET_GETOPT_option_loglevel (char **level)
419{ 408{
420 struct GNUNET_GETOPT_CommandLineOption clo = { 409 struct GNUNET_GETOPT_CommandLineOption clo =
421 .shortName = 'L', 410 {.shortName = 'L',
422 .name = "log", 411 .name = "log",
423 .argumentHelp = "LOGLEVEL", 412 .argumentHelp = "LOGLEVEL",
424 .description = gettext_noop("configure logging to use LOGLEVEL"), 413 .description = gettext_noop ("configure logging to use LOGLEVEL"),
425 .require_argument = 1, 414 .require_argument = 1,
426 .processor = &set_string, 415 .processor = &set_string,
427 .scls = (void *) level 416 .scls = (void *) level};
428 };
429 417
430 return clo; 418 return clo;
431} 419}
@@ -470,20 +458,18 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
470 */ 458 */
471struct GNUNET_GETOPT_CommandLineOption 459struct GNUNET_GETOPT_CommandLineOption
472GNUNET_GETOPT_option_filename (char shortName, 460GNUNET_GETOPT_option_filename (char shortName,
473 const char *name, 461 const char *name,
474 const char *argumentHelp, 462 const char *argumentHelp,
475 const char *description, 463 const char *description,
476 char **str) 464 char **str)
477{ 465{
478 struct GNUNET_GETOPT_CommandLineOption clo = { 466 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
479 .shortName = shortName, 467 .name = name,
480 .name = name, 468 .argumentHelp = argumentHelp,
481 .argumentHelp = argumentHelp, 469 .description = description,
482 .description = description, 470 .require_argument = 1,
483 .require_argument = 1, 471 .processor = &set_filename,
484 .processor = &set_filename, 472 .scls = (void *) str};
485 .scls = (void *) str
486 };
487 473
488 return clo; 474 return clo;
489} 475}
@@ -497,15 +483,15 @@ GNUNET_GETOPT_option_filename (char shortName,
497struct GNUNET_GETOPT_CommandLineOption 483struct GNUNET_GETOPT_CommandLineOption
498GNUNET_GETOPT_option_logfile (char **logfn) 484GNUNET_GETOPT_option_logfile (char **logfn)
499{ 485{
500 struct GNUNET_GETOPT_CommandLineOption clo = { 486 struct GNUNET_GETOPT_CommandLineOption clo =
501 .shortName = 'l', 487 {.shortName = 'l',
502 .name = "logfile", 488 .name = "logfile",
503 .argumentHelp = "FILENAME", 489 .argumentHelp = "FILENAME",
504 .description = gettext_noop ("configure logging to write logs to FILENAME"), 490 .description =
505 .require_argument = 1, 491 gettext_noop ("configure logging to write logs to FILENAME"),
506 .processor = &set_filename, 492 .require_argument = 1,
507 .scls = (void *) logfn 493 .processor = &set_filename,
508 }; 494 .scls = (void *) logfn};
509 495
510 return clo; 496 return clo;
511} 497}
@@ -519,15 +505,14 @@ GNUNET_GETOPT_option_logfile (char **logfn)
519struct GNUNET_GETOPT_CommandLineOption 505struct GNUNET_GETOPT_CommandLineOption
520GNUNET_GETOPT_option_cfgfile (char **fn) 506GNUNET_GETOPT_option_cfgfile (char **fn)
521{ 507{
522 struct GNUNET_GETOPT_CommandLineOption clo = { 508 struct GNUNET_GETOPT_CommandLineOption clo =
523 .shortName = 'c', 509 {.shortName = 'c',
524 .name = "config", 510 .name = "config",
525 .argumentHelp = "FILENAME", 511 .argumentHelp = "FILENAME",
526 .description = gettext_noop("use configuration file FILENAME"), 512 .description = gettext_noop ("use configuration file FILENAME"),
527 .require_argument = 1, 513 .require_argument = 1,
528 .processor = &set_filename, 514 .processor = &set_filename,
529 .scls = (void *) fn 515 .scls = (void *) fn};
530 };
531 516
532 return clo; 517 return clo;
533} 518}
@@ -556,13 +541,10 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
556 char dummy[2]; 541 char dummy[2];
557 542
558 (void) ctx; 543 (void) ctx;
559 if (1 != SSCANF (value, 544 if (1 != SSCANF (value, "%llu%1s", val, dummy))
560 "%llu%1s",
561 val,
562 dummy))
563 { 545 {
564 FPRINTF (stderr, 546 FPRINTF (stderr,
565 _("You must pass a number to the `%s' option.\n"), 547 _ ("You must pass a number to the `%s' option.\n"),
566 option); 548 option);
567 return GNUNET_SYSERR; 549 return GNUNET_SYSERR;
568 } 550 }
@@ -581,20 +563,18 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
581 */ 563 */
582struct GNUNET_GETOPT_CommandLineOption 564struct GNUNET_GETOPT_CommandLineOption
583GNUNET_GETOPT_option_ulong (char shortName, 565GNUNET_GETOPT_option_ulong (char shortName,
584 const char *name, 566 const char *name,
585 const char *argumentHelp, 567 const char *argumentHelp,
586 const char *description, 568 const char *description,
587 unsigned long long *val) 569 unsigned long long *val)
588{ 570{
589 struct GNUNET_GETOPT_CommandLineOption clo = { 571 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
590 .shortName = shortName, 572 .name = name,
591 .name = name, 573 .argumentHelp = argumentHelp,
592 .argumentHelp = argumentHelp, 574 .description = description,
593 .description = description, 575 .require_argument = 1,
594 .require_argument = 1, 576 .processor = &set_ulong,
595 .processor = &set_ulong, 577 .scls = (void *) val};
596 .scls = (void *) val
597 };
598 578
599 return clo; 579 return clo;
600} 580}
@@ -620,14 +600,12 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
620 const char *value) 600 const char *value)
621{ 601{
622 struct GNUNET_TIME_Relative *val = scls; 602 struct GNUNET_TIME_Relative *val = scls;
623 603
624 (void) ctx; 604 (void) ctx;
625 if (GNUNET_OK != 605 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (value, val))
626 GNUNET_STRINGS_fancy_time_to_relative (value,
627 val))
628 { 606 {
629 FPRINTF (stderr, 607 FPRINTF (stderr,
630 _("You must pass relative time to the `%s' option.\n"), 608 _ ("You must pass relative time to the `%s' option.\n"),
631 option); 609 option);
632 return GNUNET_SYSERR; 610 return GNUNET_SYSERR;
633 } 611 }
@@ -647,20 +625,18 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
647 */ 625 */
648struct GNUNET_GETOPT_CommandLineOption 626struct GNUNET_GETOPT_CommandLineOption
649GNUNET_GETOPT_option_relative_time (char shortName, 627GNUNET_GETOPT_option_relative_time (char shortName,
650 const char *name, 628 const char *name,
651 const char *argumentHelp, 629 const char *argumentHelp,
652 const char *description, 630 const char *description,
653 struct GNUNET_TIME_Relative *val) 631 struct GNUNET_TIME_Relative *val)
654{ 632{
655 struct GNUNET_GETOPT_CommandLineOption clo = { 633 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
656 .shortName = shortName, 634 .name = name,
657 .name = name, 635 .argumentHelp = argumentHelp,
658 .argumentHelp = argumentHelp, 636 .description = description,
659 .description = description, 637 .require_argument = 1,
660 .require_argument = 1, 638 .processor = &set_relative_time,
661 .processor = &set_relative_time, 639 .scls = (void *) val};
662 .scls = (void *) val
663 };
664 640
665 return clo; 641 return clo;
666} 642}
@@ -688,12 +664,10 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
688 struct GNUNET_TIME_Absolute *val = scls; 664 struct GNUNET_TIME_Absolute *val = scls;
689 665
690 (void) ctx; 666 (void) ctx;
691 if (GNUNET_OK != 667 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (value, val))
692 GNUNET_STRINGS_fancy_time_to_absolute (value,
693 val))
694 { 668 {
695 FPRINTF (stderr, 669 FPRINTF (stderr,
696 _("You must pass absolute time to the `%s' option.\n"), 670 _ ("You must pass absolute time to the `%s' option.\n"),
697 option); 671 option);
698 return GNUNET_SYSERR; 672 return GNUNET_SYSERR;
699 } 673 }
@@ -713,20 +687,18 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
713 */ 687 */
714struct GNUNET_GETOPT_CommandLineOption 688struct GNUNET_GETOPT_CommandLineOption
715GNUNET_GETOPT_option_absolute_time (char shortName, 689GNUNET_GETOPT_option_absolute_time (char shortName,
716 const char *name, 690 const char *name,
717 const char *argumentHelp, 691 const char *argumentHelp,
718 const char *description, 692 const char *description,
719 struct GNUNET_TIME_Absolute *val) 693 struct GNUNET_TIME_Absolute *val)
720{ 694{
721 struct GNUNET_GETOPT_CommandLineOption clo = { 695 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
722 .shortName = shortName, 696 .name = name,
723 .name = name, 697 .argumentHelp = argumentHelp,
724 .argumentHelp = argumentHelp, 698 .description = description,
725 .description = description, 699 .require_argument = 1,
726 .require_argument = 1, 700 .processor = &set_absolute_time,
727 .processor = &set_absolute_time, 701 .scls = (void *) val};
728 .scls = (void *) val
729 };
730 702
731 return clo; 703 return clo;
732} 704}
@@ -755,20 +727,18 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
755 char dummy[2]; 727 char dummy[2];
756 728
757 (void) ctx; 729 (void) ctx;
758 if('-' == *value) 730 if ('-' == *value)
759 { 731 {
760 FPRINTF (stderr, 732 FPRINTF (stderr,
761 _("Your input for the '%s' option has to be a non negative number \n"), 733 _ (
762 option); 734 "Your input for the '%s' option has to be a non negative number \n"),
763 return GNUNET_SYSERR; 735 option);
736 return GNUNET_SYSERR;
764 } 737 }
765 if (1 != SSCANF (value, 738 if (1 != SSCANF (value, "%u%1s", val, dummy))
766 "%u%1s",
767 val,
768 dummy))
769 { 739 {
770 FPRINTF (stderr, 740 FPRINTF (stderr,
771 _("You must pass a number to the `%s' option.\n"), 741 _ ("You must pass a number to the `%s' option.\n"),
772 option); 742 option);
773 return GNUNET_SYSERR; 743 return GNUNET_SYSERR;
774 } 744 }
@@ -787,26 +757,23 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
787 */ 757 */
788struct GNUNET_GETOPT_CommandLineOption 758struct GNUNET_GETOPT_CommandLineOption
789GNUNET_GETOPT_option_uint (char shortName, 759GNUNET_GETOPT_option_uint (char shortName,
790 const char *name, 760 const char *name,
791 const char *argumentHelp, 761 const char *argumentHelp,
792 const char *description, 762 const char *description,
793 unsigned int *val) 763 unsigned int *val)
794{ 764{
795 struct GNUNET_GETOPT_CommandLineOption clo = { 765 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
796 .shortName = shortName, 766 .name = name,
797 .name = name, 767 .argumentHelp = argumentHelp,
798 .argumentHelp = argumentHelp, 768 .description = description,
799 .description = description, 769 .require_argument = 1,
800 .require_argument = 1, 770 .processor = &set_uint,
801 .processor = &set_uint, 771 .scls = (void *) val};
802 .scls = (void *) val
803 };
804 772
805 return clo; 773 return clo;
806} 774}
807 775
808 776
809
810/** 777/**
811 * Set an option of type 'uint16_t' from the command line. 778 * Set an option of type 'uint16_t' from the command line.
812 * A pointer to this function should be passed as part of the 779 * A pointer to this function should be passed as part of the
@@ -822,30 +789,27 @@ GNUNET_GETOPT_option_uint (char shortName,
822 */ 789 */
823static int 790static int
824set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 791set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
825 void *scls, 792 void *scls,
826 const char *option, 793 const char *option,
827 const char *value) 794 const char *value)
828{ 795{
829 uint16_t *val = scls; 796 uint16_t *val = scls;
830 unsigned int v; 797 unsigned int v;
831 char dummy[2]; 798 char dummy[2];
832 799
833 (void) ctx; 800 (void) ctx;
834 if (1 != SSCANF (value, 801 if (1 != SSCANF (value, "%u%1s", &v, dummy))
835 "%u%1s",
836 &v,
837 dummy))
838 { 802 {
839 FPRINTF (stderr, 803 FPRINTF (stderr,
840 _("You must pass a number to the `%s' option.\n"), 804 _ ("You must pass a number to the `%s' option.\n"),
841 option); 805 option);
842 return GNUNET_SYSERR; 806 return GNUNET_SYSERR;
843 } 807 }
844 if (v > UINT16_MAX) 808 if (v > UINT16_MAX)
845 { 809 {
846 FPRINTF (stderr, 810 FPRINTF (stderr,
847 _("You must pass a number below %u to the `%s' option.\n"), 811 _ ("You must pass a number below %u to the `%s' option.\n"),
848 (unsigned int) UINT16_MAX, 812 (unsigned int) UINT16_MAX,
849 option); 813 option);
850 return GNUNET_SYSERR; 814 return GNUNET_SYSERR;
851 } 815 }
@@ -865,20 +829,18 @@ set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
865 */ 829 */
866struct GNUNET_GETOPT_CommandLineOption 830struct GNUNET_GETOPT_CommandLineOption
867GNUNET_GETOPT_option_uint16 (char shortName, 831GNUNET_GETOPT_option_uint16 (char shortName,
868 const char *name, 832 const char *name,
869 const char *argumentHelp, 833 const char *argumentHelp,
870 const char *description, 834 const char *description,
871 uint16_t *val) 835 uint16_t *val)
872{ 836{
873 struct GNUNET_GETOPT_CommandLineOption clo = { 837 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
874 .shortName = shortName, 838 .name = name,
875 .name = name, 839 .argumentHelp = argumentHelp,
876 .argumentHelp = argumentHelp, 840 .description = description,
877 .description = description, 841 .require_argument = 1,
878 .require_argument = 1, 842 .processor = &set_uint16,
879 .processor = &set_uint16, 843 .scls = (void *) val};
880 .scls = (void *) val
881 };
882 844
883 return clo; 845 return clo;
884} 846}
@@ -923,15 +885,16 @@ set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
923 struct Base32Context *bc = scls; 885 struct Base32Context *bc = scls;
924 886
925 (void) ctx; 887 (void) ctx;
926 if (GNUNET_OK != 888 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (value,
927 GNUNET_STRINGS_string_to_data (value, 889 strlen (value),
928 strlen (value), 890 bc->val,
929 bc->val, 891 bc->val_size))
930 bc->val_size))
931 { 892 {
932 fprintf (stderr, 893 fprintf (
933 _("Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"), 894 stderr,
934 option); 895 _ (
896 "Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"),
897 option);
935 return GNUNET_SYSERR; 898 return GNUNET_SYSERR;
936 } 899 }
937 return GNUNET_OK; 900 return GNUNET_OK;
@@ -964,23 +927,21 @@ free_bc (void *cls)
964 */ 927 */
965struct GNUNET_GETOPT_CommandLineOption 928struct GNUNET_GETOPT_CommandLineOption
966GNUNET_GETOPT_option_base32_fixed_size (char shortName, 929GNUNET_GETOPT_option_base32_fixed_size (char shortName,
967 const char *name, 930 const char *name,
968 const char *argumentHelp, 931 const char *argumentHelp,
969 const char *description, 932 const char *description,
970 void *val, 933 void *val,
971 size_t val_size) 934 size_t val_size)
972{ 935{
973 struct Base32Context *bc = GNUNET_new (struct Base32Context); 936 struct Base32Context *bc = GNUNET_new (struct Base32Context);
974 struct GNUNET_GETOPT_CommandLineOption clo = { 937 struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
975 .shortName = shortName, 938 .name = name,
976 .name = name, 939 .argumentHelp = argumentHelp,
977 .argumentHelp = argumentHelp, 940 .description = description,
978 .description = description, 941 .require_argument = 1,
979 .require_argument = 1, 942 .processor = &set_base32,
980 .processor = &set_base32, 943 .cleaner = &free_bc,
981 .cleaner = &free_bc, 944 .scls = (void *) bc};
982 .scls = (void *) bc
983 };
984 945
985 bc->val = val; 946 bc->val = val;
986 bc->val_size = val_size; 947 bc->val_size = val_size;
@@ -1002,4 +963,18 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt)
1002} 963}
1003 964
1004 965
966/**
967 * Make the given option mutually exclusive with other options.
968 *
969 * @param opt option to modify
970 * @return @a opt with the exclusive flag set.
971 */
972struct GNUNET_GETOPT_CommandLineOption
973GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt)
974{
975 opt.option_exclusive = 1;
976 return opt;
977}
978
979
1005/* end of getopt_helpers.c */ 980/* end of getopt_helpers.c */
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 9c292205a..3b9b64d4e 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -103,18 +103,12 @@ print_option (void *cls,
103 fn = value_fn; 103 fn = value_fn;
104 else 104 else
105 GNUNET_free (value_fn); 105 GNUNET_free (value_fn);
106 fprintf (stdout, 106 fprintf (stdout, "%s = %s\n", option, fn);
107 "%s = %s\n",
108 option,
109 fn);
110 GNUNET_free (fn); 107 GNUNET_free (fn);
111 } 108 }
112 else 109 else
113 { 110 {
114 fprintf (stdout, 111 fprintf (stdout, "%s = %s\n", option, value);
115 "%s = %s\n",
116 option,
117 value);
118 } 112 }
119} 113}
120 114
@@ -126,13 +120,10 @@ print_option (void *cls,
126 * @param section a section in the configuration file 120 * @param section a section in the configuration file
127 */ 121 */
128static void 122static void
129print_section_name (void *cls, 123print_section_name (void *cls, const char *section)
130 const char *section)
131{ 124{
132 (void) cls; 125 (void) cls;
133 fprintf (stdout, 126 fprintf (stdout, "%s\n", section);
134 "%s\n",
135 section);
136} 127}
137 128
138 129
@@ -161,9 +152,7 @@ run (void *cls,
161 { 152 {
162 char *name; 153 char *name;
163 154
164 GNUNET_asprintf (&name, 155 GNUNET_asprintf (&name, "libgnunet_plugin_%s", backend_check);
165 "libgnunet_plugin_%s",
166 backend_check);
167 global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77; 156 global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77;
168 GNUNET_free (name); 157 GNUNET_free (name);
169 return; 158 return;
@@ -173,40 +162,34 @@ run (void *cls,
173 struct GNUNET_CONFIGURATION_Handle *def; 162 struct GNUNET_CONFIGURATION_Handle *def;
174 163
175 def = GNUNET_CONFIGURATION_create (); 164 def = GNUNET_CONFIGURATION_create ();
176 if (GNUNET_OK != 165 if (GNUNET_OK != GNUNET_CONFIGURATION_load (def, NULL))
177 GNUNET_CONFIGURATION_load (def, NULL))
178 { 166 {
179 fprintf (stderr, 167 fprintf (stderr, _ ("failed to load configuration defaults"));
180 _("failed to load configuration defaults"));
181 global_ret = 1; 168 global_ret = 1;
182 return; 169 return;
183 } 170 }
184 diff = GNUNET_CONFIGURATION_get_diff (def, 171 diff = GNUNET_CONFIGURATION_get_diff (def, cfg);
185 cfg);
186 cfg = diff; 172 cfg = diff;
187 } 173 }
188 if ( ((! rewrite) && (NULL == section)) || list_sections) 174 if (((! rewrite) && (NULL == section)) || list_sections)
189 { 175 {
190 if (! list_sections) 176 if (! list_sections)
191 { 177 {
192 fprintf (stderr, 178 fprintf (stderr,
193 _("%s or %s argument is required\n"), 179 _ ("%s or %s argument is required\n"),
194 "--section", 180 "--section",
195 "--list-sections"); 181 "--list-sections");
196 global_ret = 1; 182 global_ret = 1;
197 } 183 }
198 else 184 else
199 { 185 {
200 fprintf (stderr, 186 fprintf (stderr, _ ("The following sections are available:\n"));
201 _("The following sections are available:\n")); 187 GNUNET_CONFIGURATION_iterate_sections (cfg, &print_section_name, NULL);
202 GNUNET_CONFIGURATION_iterate_sections (cfg,
203 &print_section_name,
204 NULL);
205 } 188 }
206 goto cleanup; 189 goto cleanup;
207 } 190 }
208 191
209 if ( (NULL != section) && (NULL == value) ) 192 if ((NULL != section) && (NULL == value))
210 { 193 {
211 if (NULL == option) 194 if (NULL == option)
212 { 195 {
@@ -219,26 +202,24 @@ run (void *cls,
219 { 202 {
220 if (is_filename) 203 if (is_filename)
221 { 204 {
222 if (GNUNET_OK != 205 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
223 GNUNET_CONFIGURATION_get_value_filename (cfg, 206 section,
224 section, 207 option,
225 option, 208 &value))
226 &value))
227 { 209 {
228 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 210 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
229 section, option);
230 global_ret = 3; 211 global_ret = 3;
231 goto cleanup; 212 goto cleanup;
232 } 213 }
233 } 214 }
234 else 215 else
235 { 216 {
236 if (GNUNET_OK != 217 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
237 GNUNET_CONFIGURATION_get_value_string (cfg, section, 218 section,
238 option, &value)) 219 option,
220 &value))
239 { 221 {
240 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 222 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
241 section, option);
242 global_ret = 3; 223 global_ret = 3;
243 goto cleanup; 224 goto cleanup;
244 } 225 }
@@ -250,15 +231,12 @@ run (void *cls,
250 { 231 {
251 if (NULL == option) 232 if (NULL == option)
252 { 233 {
253 fprintf (stderr, _("--option argument required to set value\n")); 234 fprintf (stderr, _ ("--option argument required to set value\n"));
254 global_ret = 1; 235 global_ret = 1;
255 goto cleanup; 236 goto cleanup;
256 } 237 }
257 out = GNUNET_CONFIGURATION_dup (cfg); 238 out = GNUNET_CONFIGURATION_dup (cfg);
258 GNUNET_CONFIGURATION_set_value_string (out, 239 GNUNET_CONFIGURATION_set_value_string (out, section, option, value);
259 section,
260 option,
261 value);
262 } 240 }
263 cfg_fn = NULL; 241 cfg_fn = NULL;
264 if (NULL == cfgfile) 242 if (NULL == cfgfile)
@@ -274,11 +252,10 @@ run (void *cls,
274 cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); 252 cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
275 cfgfile = cfg_fn; 253 cfgfile = cfg_fn;
276 } 254 }
277 if ( (NULL != diff) || (NULL != out) ) 255 if ((NULL != diff) || (NULL != out))
278 { 256 {
279 if (GNUNET_OK != 257 if (GNUNET_OK !=
280 GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, 258 GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, cfgfile))
281 cfgfile))
282 global_ret = 2; 259 global_ret = 2;
283 } 260 }
284 GNUNET_free_non_null (cfg_fn); 261 GNUNET_free_non_null (cfg_fn);
@@ -298,62 +275,66 @@ cleanup:
298 * @return 0 ok, 1 on error 275 * @return 0 ok, 1 on error
299 */ 276 */
300int 277int
301main (int argc, 278main (int argc, char *const *argv)
302 char *const *argv)
303{ 279{
304 struct GNUNET_GETOPT_CommandLineOption options[] = { 280 struct GNUNET_GETOPT_CommandLineOption options[] =
305 GNUNET_GETOPT_option_flag ('f', 281 {GNUNET_GETOPT_option_flag (
306 "filename", 282 'f',
307 gettext_noop ("interpret option value as a filename (with $-expansion)"), 283 "filename",
308 &is_filename), 284 gettext_noop ("interpret option value as a filename (with $-expansion)"),
309 //GNUNET_GETOPT_option_exclusive 285 &is_filename),
310 (GNUNET_GETOPT_option_string ('b', 286 GNUNET_GETOPT_option_exclusive (GNUNET_GETOPT_option_string (
311 "supported-backend", 287 'b',
312 "BACKEND", 288 "supported-backend",
313 gettext_noop ("test if the current installation supports the specified BACKEND"), 289 "BACKEND",
314 &backend_check)), 290 gettext_noop (
315 GNUNET_GETOPT_option_string ('s', 291 "test if the current installation supports the specified BACKEND"),
316 "section", 292 &backend_check)),
317 "SECTION", 293 GNUNET_GETOPT_option_string ('s',
318 gettext_noop ("name of the section to access"), 294 "section",
319 &section), 295 "SECTION",
320 GNUNET_GETOPT_option_string ('o', 296 gettext_noop (
321 "option", 297 "name of the section to access"),
322 "OPTION", 298 &section),
323 gettext_noop ("name of the option to access"), 299 GNUNET_GETOPT_option_string ('o',
324 &option), 300 "option",
325 GNUNET_GETOPT_option_string ('V', 301 "OPTION",
326 "value", 302 gettext_noop ("name of the option to access"),
327 "VALUE", 303 &option),
328 gettext_noop ("value to set"), 304 GNUNET_GETOPT_option_string ('V',
329 &value), 305 "value",
330 GNUNET_GETOPT_option_flag ('S', 306 "VALUE",
331 "list-sections", 307 gettext_noop ("value to set"),
332 gettext_noop ("print available configuration sections"), 308 &value),
333 &list_sections), 309 GNUNET_GETOPT_option_flag ('S',
334 GNUNET_GETOPT_option_flag ('w', 310 "list-sections",
335 "rewrite", 311 gettext_noop (
336 gettext_noop ("write configuration file that only contains delta to defaults"), 312 "print available configuration sections"),
337 &rewrite), 313 &list_sections),
338 GNUNET_GETOPT_OPTION_END 314 GNUNET_GETOPT_option_flag (
339 }; 315 'w',
316 "rewrite",
317 gettext_noop (
318 "write configuration file that only contains delta to defaults"),
319 &rewrite),
320 GNUNET_GETOPT_OPTION_END};
340 int ret; 321 int ret;
341 322
342 if (GNUNET_OK != 323 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
343 GNUNET_STRINGS_get_utf8_args (argc, argv,
344 &argc, &argv))
345 return 2; 324 return 2;
346 325
347 ret = GNUNET_PROGRAM_run (argc, 326 ret =
348 argv, 327 GNUNET_PROGRAM_run (argc,
349 "gnunet-config [OPTIONS]", 328 argv,
350 gettext_noop ("Manipulate GNUnet configuration files"), 329 "gnunet-config [OPTIONS]",
351 options, 330 gettext_noop ("Manipulate GNUnet configuration files"),
352 &run, NULL); 331 options,
353 GNUNET_free ((void*) argv); 332 &run,
333 NULL);
334 GNUNET_free ((void *) argv);
354 if (GNUNET_OK == ret) 335 if (GNUNET_OK == ret)
355 return global_ret; 336 return global_ret;
356 return 1; 337 return ret;
357} 338}
358 339
359/* end of gnunet-config.c */ 340/* end of gnunet-config.c */