gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: finish #4623


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: finish #4623
Date: Sat, 22 Jun 2019 23:29:54 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 988ac7f12 finish #4623
988ac7f12 is described below

commit 988ac7f121b646cba3ca44567f54b1315398505d
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Jun 22 23:28:58 2019 +0200

    finish #4623
---
 src/arm/gnunet-arm.c             |  21 +-
 src/cadet/gnunet-service-cadet.c |   1 -
 src/include/gnunet_getopt_lib.h  |  60 ++++--
 src/namestore/gnunet-namestore.c |  18 +-
 src/util/getopt.c                | 200 ++++++++++--------
 src/util/getopt_helpers.c        | 441 ++++++++++++++++++---------------------
 src/util/gnunet-config.c         | 181 +++++++---------
 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)
        gettext_noop ("don't let gnunet-service-arm inherit standard error"),
        &no_stderr),
      GNUNET_GETOPT_OPTION_END};
+  int lret;
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   if (GNUNET_OK ==
-      GNUNET_PROGRAM_run (
-        argc,
-        argv,
-        "gnunet-arm",
-        gettext_noop (
-          "Control services and the Automated Restart Manager (ARM)"),
-        options,
-        &run,
-        NULL))
+      (lret = GNUNET_PROGRAM_run (
+         argc,
+         argv,
+         "gnunet-arm",
+         gettext_noop (
+           "Control services and the Automated Restart Manager (ARM)"),
+         options,
+         &run,
+         NULL)))
   {
     GNUNET_free ((void *) argv);
     return ret;
   }
   GNUNET_free ((void *) argv);
-  return 1;
+  return lret;
 }
 
 /* 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 @@
  * - channel: logical link between two clients, on the same or different peers.
  *            have properties like reliability.
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #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 @@
 #define GNUNET_GETOPT_LIB_H
 
 #ifdef __cplusplus
-extern "C"
-{
-#if 0                           /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
 }
 #endif
 #endif
@@ -77,7 +76,6 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
    * Current argument.
    */
   unsigned int currentArgument;
-
 };
 
 
@@ -90,12 +88,11 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
  * @param value argument, NULL if none was given
  * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to 
abort
  */
-typedef int
-(*GNUNET_GETOPT_CommandLineOptionProcessor) (struct
-                                             
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
-                                             void *scls,
-                                             const char *option,
-                                             const char *value);
+typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (
+  struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+  void *scls,
+  const char *option,
+  const char *value);
 
 
 /**
@@ -149,13 +146,12 @@ struct GNUNET_GETOPT_CommandLineOption
    * Function to call on @e scls to clean up after processing all
    * the arguments. Can be NULL.
    */
-  void (*cleaner)(void *cls);
+  void (*cleaner) (void *cls);
 
   /**
    * Specific closure to pass to the processor.
    */
   void *scls;
-
 };
 
 
@@ -179,7 +175,6 @@ struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_version (const char *version);
 
 
-
 /**
  * Allow user to specify log file name (-l option)
  *
@@ -254,8 +249,17 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
  * @param[out] val binary value decoded from Crockford Base32-encoded argument;
  *             size is determined by type (sizeof (*val)).
  */
-#define 
GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \
-  
GNUNET_GETOPT_option_base32_fixed_size(shortName,name,argumentHelp,description,val,sizeof(*val))
+#define GNUNET_GETOPT_option_base32_auto(shortName,     \
+                                         name,          \
+                                         argumentHelp,  \
+                                         description,   \
+                                         val)           \
+  GNUNET_GETOPT_option_base32_fixed_size (shortName,    \
+                                          name,         \
+                                          argumentHelp, \
+                                          description,  \
+                                          val,          \
+                                          sizeof (*val))
 
 
 /**
@@ -302,10 +306,10 @@ GNUNET_GETOPT_option_uint (char shortName,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_uint16 (char shortName,
-                            const char *name,
-                            const char *argumentHelp,
-                            const char *description,
-                            uint16_t *val);
+                             const char *name,
+                             const char *argumentHelp,
+                             const char *description,
+                             uint16_t *val);
 
 
 /**
@@ -425,11 +429,23 @@ struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
 
 
+/**
+ * Make the given option mutually exclusive with other options.
+ *
+ * @param opt option to modify
+ * @return @a opt with the exclusive flag set.
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt);
+
+
 /**
  * Marker for the end of the list of options.
  */
-#define GNUNET_GETOPT_OPTION_END \
-  { '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
+#define GNUNET_GETOPT_OPTION_END                      \
+  {                                                   \
+    '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
+  }
 
 
 /**
@@ -449,7 +465,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
                    char *const *argv);
 
 
-#if 0                           /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
 {
 #endif
 #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)
                                     "name of the ego controlling the zone"),
                                   &ego_name),
      GNUNET_GETOPT_OPTION_END};
+  int lret;
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
@@ -1654,17 +1655,18 @@ main (int argc, char *const *argv)
   is_public = -1;
   is_shadow = -1;
   GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
-  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
-                                       argv,
-                                       "gnunet-namestore",
-                                       _ ("GNUnet zone manipulation tool"),
-                                       options,
-                                       &run,
-                                       NULL))
+  if (GNUNET_OK !=
+      (lret = GNUNET_PROGRAM_run (argc,
+                                  argv,
+                                  "gnunet-namestore",
+                                  _ ("GNUnet zone manipulation tool"),
+                                  options,
+                                  &run,
+                                  NULL)))
   {
     GNUNET_free ((void *) argv);
     GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
-    return 1;
+    return lret;
   }
   GNUNET_free ((void *) argv);
   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
 #endif
 #endif
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, 
"util-getopt", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-getopt", syscall)
 
-#if defined (WIN32) && !defined (__CYGWIN32__)
+#if defined(WIN32) && ! defined(__CYGWIN32__)
 /* It's not Unix, really.  See?  Capital letters.  */
 #include <windows.h>
-#define getpid() GetCurrentProcessId()
+#define getpid() GetCurrentProcessId ()
 #endif
 
 #ifndef _
@@ -62,9 +63,9 @@ Copyright (C) 2006, 2017 Christian Grothoff
    When compiling libc, the _ macro is predefined.  */
 #ifdef HAVE_LIBINTL_H
 #include <libintl.h>
-#define _(msgid)  gettext (msgid)
+#define _(msgid) gettext (msgid)
 #else
-#define _(msgid)  (msgid)
+#define _(msgid) (msgid)
 #endif
 #endif
 
@@ -176,21 +177,18 @@ static char *nextchar;
    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
    `--' can cause `getopt' to return -1 with `GNoptind' != ARGC.  */
 
-static enum
-{
-  REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
+static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
 
 /* Value of POSIXLY_CORRECT environment variable.  */
 static char *posixly_correct;
 
-#ifdef  __GNU_LIBRARY__
+#ifdef __GNU_LIBRARY__
 /* We want to avoid inclusion of string.h with non-GNU libraries
    because there are many ways it can cause trouble.
    On some systems, it contains special magic macros that don't work
    in GCC.  */
 #include <string.h>
-#define  my_index      strchr
+#define my_index strchr
 #else
 
 /* Avoid depending on library functions or files
@@ -200,8 +198,7 @@ char *
 getenv ();
 
 static char *
-my_index (const char *str,
-         int chr)
+my_index (const char *str, int chr)
 {
   while (*str)
   {
@@ -217,7 +214,7 @@ my_index (const char *str,
 #ifdef __GNUC__
 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
    That was relevant to code that was here before.  */
-#if !defined (__STDC__) || !__STDC__
+#if ! defined(__STDC__) || ! __STDC__
 /* gcc with -traditional declares the built-in strlen to return int,
    and has done so at least since version 2.4.5. -- rms.  */
 extern int
@@ -247,7 +244,7 @@ static int last_nonopt;
    `first_nonopt' and `last_nonopt' are relocated so that they describe
    the new indices of the non-options in ARGV after they are moved.  */
 
-#if defined (__STDC__) && __STDC__
+#if defined(__STDC__) && __STDC__
 static void
 exchange (char **);
 #endif
@@ -311,14 +308,12 @@ exchange (char **argv)
 
 /* Initialize the internal data when the first call is made.  */
 
-#if defined (__STDC__) && __STDC__
+#if defined(__STDC__) && __STDC__
 static const char *
 _getopt_initialize (int, char *const *, const char *);
 #endif
 static const char *
-_getopt_initialize (int argc,
-                   char *const *argv,
-                   const char *optstring)
+_getopt_initialize (int argc, char *const *argv, const char *optstring)
 {
   /* Start processing options with ARGV-element 1 (since ARGV-element 0
    * is the program name); the sequence of previously skipped
@@ -407,8 +402,11 @@ _getopt_initialize (int argc,
    long-named options.  */
 
 static int
-GN_getopt_internal (int argc, char *const *argv, const char *optstring,
-                    const struct GNoption *longopts, int *longind,
+GN_getopt_internal (int argc,
+                    char *const *argv,
+                    const char *optstring,
+                    const struct GNoption *longopts,
+                    int *longind,
                     int long_only)
 {
   static int __getopt_initialized = 0;
@@ -416,10 +414,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
 
   GNoptarg = NULL;
 
-  if (GNoptind == 0 || !__getopt_initialized)
+  if (GNoptind == 0 || ! __getopt_initialized)
   {
     if (GNoptind == 0)
-      GNoptind = 1;             /* Don't scan ARGV[0], the program name.  */
+      GNoptind = 1; /* Don't scan ARGV[0], the program name.  */
     optstring = _getopt_initialize (argc, argv, optstring);
     __getopt_initialized = 1;
   }
@@ -463,7 +461,7 @@ GN_getopt_internal (int argc, char *const *argv, const char 
*optstring,
      * Skip it like a null option,
      * then exchange with previous non-options as if it were an option,
      * then skip everything else like a non-option.  */
-    if (GNoptind != argc && !strcmp (argv[GNoptind], "--"))
+    if (GNoptind != argc && ! strcmp (argv[GNoptind], "--"))
     {
       GNoptind++;
 
@@ -503,7 +501,7 @@ GN_getopt_internal (int argc, char *const *argv, const char 
*optstring,
      * Skip the initial punctuation.  */
 
     nextchar =
-        (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));
+      (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));
   }
 
   /* Decode the current option-ARGV-element.  */
@@ -524,7 +522,7 @@ GN_getopt_internal (int argc, char *const *argv, const char 
*optstring,
   if (longopts != NULL &&
       (argv[GNoptind][1] == '-' ||
        (long_only &&
-        (argv[GNoptind][2] || !my_index (optstring, argv[GNoptind][1])))))
+        (argv[GNoptind][2] || ! my_index (optstring, argv[GNoptind][1])))))
   {
     char *nameend;
     const struct GNoption *p;
@@ -535,12 +533,12 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
     int option_index;
 
     for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
-      /* Do nothing.  */ ;
+      /* Do nothing.  */;
 
     /* Test all long options for either exact match
      * or abbreviated matches.  */
     for (p = longopts, option_index = 0; p->name; p++, option_index++)
-      if (!strncmp (p->name, nextchar, nameend - nextchar))
+      if (! strncmp (p->name, nextchar, nameend - nextchar))
       {
         if ((unsigned int) (nameend - nextchar) ==
             (unsigned int) strlen (p->name))
@@ -562,10 +560,12 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
           ambig = 1;
       }
 
-    if (ambig && !exact)
+    if (ambig && ! exact)
     {
       if (GNopterr)
-        FPRINTF (stderr, _("%s: option `%s' is ambiguous\n"), argv[0],
+        FPRINTF (stderr,
+                 _ ("%s: option `%s' is ambiguous\n"),
+                 argv[0],
                  argv[GNoptind]);
       nextchar += strlen (nextchar);
       GNoptind++;
@@ -589,13 +589,16 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
             if (argv[GNoptind - 1][1] == '-')
               /* --option */
               FPRINTF (stderr,
-                       _("%s: option `--%s' does not allow an argument\n"),
-                       argv[0], pfound->name);
+                       _ ("%s: option `--%s' does not allow an argument\n"),
+                       argv[0],
+                       pfound->name);
             else
               /* +option or -option */
               FPRINTF (stderr,
-                       _("%s: option `%c%s' does not allow an argument\n"),
-                       argv[0], argv[GNoptind - 1][0], pfound->name);
+                       _ ("%s: option `%c%s' does not allow an argument\n"),
+                       argv[0],
+                       argv[GNoptind - 1][0],
+                       pfound->name);
           }
           nextchar += strlen (nextchar);
           return '?';
@@ -611,8 +614,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
         {
           if (GNopterr)
           {
-            FPRINTF (stderr, _("%s: option `%s' requires an argument\n"),
-                     argv[0], argv[GNoptind - 1]);
+            FPRINTF (stderr,
+                     _ ("%s: option `%s' requires an argument\n"),
+                     argv[0],
+                     argv[GNoptind - 1]);
           }
           nextchar += strlen (nextchar);
           return (optstring[0] == ':') ? ':' : '?';
@@ -633,19 +638,24 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
      * or the option starts with '--' or is not a valid short
      * option, then it's an error.
      * Otherwise interpret it as a short option.  */
-    if (!long_only || argv[GNoptind][1] == '-' ||
+    if (! long_only || argv[GNoptind][1] == '-' ||
         my_index (optstring, *nextchar) == NULL)
     {
       if (GNopterr)
       {
         if (argv[GNoptind][1] == '-')
           /* --option */
-          FPRINTF (stderr, _("%s: unrecognized option `--%s'\n"), argv[0],
+          FPRINTF (stderr,
+                   _ ("%s: unrecognized option `--%s'\n"),
+                   argv[0],
                    nextchar);
         else
           /* +option or -option */
-          FPRINTF (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0],
-                   argv[GNoptind][0], nextchar);
+          FPRINTF (stderr,
+                   _ ("%s: unrecognized option `%c%s'\n"),
+                   argv[0],
+                   argv[GNoptind][0],
+                   nextchar);
       }
       nextchar = (char *) "";
       GNoptind++;
@@ -669,9 +679,9 @@ GN_getopt_internal (int argc, char *const *argv, const char 
*optstring,
       {
         if (posixly_correct)
           /* 1003.2 specifies the format of this message.  */
-          FPRINTF (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+          FPRINTF (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
         else
-          FPRINTF (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+          FPRINTF (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
       }
       return '?';
     }
@@ -699,8 +709,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
         if (GNopterr)
         {
           /* 1003.2 specifies the format of this message.  */
-          FPRINTF (stderr, _("%s: option requires an argument -- %c\n"),
-                   argv[0], c);
+          FPRINTF (stderr,
+                   _ ("%s: option requires an argument -- %c\n"),
+                   argv[0],
+                   c);
         }
         if (optstring[0] == ':')
           c = ':';
@@ -718,13 +730,13 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
 
       for (nextchar = nameend = GNoptarg; *nameend && *nameend != '=';
            nameend++)
-        /* Do nothing.  */ ;
+        /* Do nothing.  */;
 
       /* Test all long options for either exact match
        * or abbreviated matches.  */
       if (longopts != NULL)
         for (p = longopts, option_index = 0; p->name; p++, option_index++)
-          if (!strncmp (p->name, nextchar, nameend - nextchar))
+          if (! strncmp (p->name, nextchar, nameend - nextchar))
           {
             if ((unsigned int) (nameend - nextchar) == strlen (p->name))
             {
@@ -744,10 +756,12 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
               /* Second or later nonexact match found.  */
               ambig = 1;
           }
-      if (ambig && !exact)
+      if (ambig && ! exact)
       {
         if (GNopterr)
-          FPRINTF (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0],
+          FPRINTF (stderr,
+                   _ ("%s: option `-W %s' is ambiguous\n"),
+                   argv[0],
                    argv[GNoptind]);
         nextchar += strlen (nextchar);
         GNoptind++;
@@ -765,7 +779,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
           else
           {
             if (GNopterr)
-              FPRINTF (stderr, _("%s: option `-W %s' does not allow an 
argument\n"), argv[0], pfound->name);
+              FPRINTF (stderr,
+                       _ ("%s: option `-W %s' does not allow an argument\n"),
+                       argv[0],
+                       pfound->name);
 
             nextchar += strlen (nextchar);
             return '?';
@@ -778,8 +795,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
           else
           {
             if (GNopterr)
-              FPRINTF (stderr, _("%s: option `%s' requires an argument\n"),
-                       argv[0], argv[GNoptind - 1]);
+              FPRINTF (stderr,
+                       _ ("%s: option `%s' requires an argument\n"),
+                       argv[0],
+                       argv[GNoptind - 1]);
             nextchar += strlen (nextchar);
             return optstring[0] == ':' ? ':' : '?';
           }
@@ -795,7 +814,7 @@ GN_getopt_internal (int argc, char *const *argv, const char 
*optstring,
         return pfound->val;
       }
       nextchar = NULL;
-      return 'W';               /* Let the application handle it.   */
+      return 'W'; /* Let the application handle it.   */
     }
     if (temp[1] == ':')
     {
@@ -826,8 +845,10 @@ GN_getopt_internal (int argc, char *const *argv, const 
char *optstring,
           if (GNopterr)
           {
             /* 1003.2 specifies the format of this message.  */
-            FPRINTF (stderr, _("%s: option requires an argument -- %c\n"),
-                     argv[0], c);
+            FPRINTF (stderr,
+                     _ ("%s: option requires an argument -- %c\n"),
+                     argv[0],
+                     c);
           }
           if (optstring[0] == ':')
             c = ':';
@@ -880,8 +901,9 @@ GNUNET_GETOPT_run (const char *binaryOptions,
   char *shorts;
   int spos;
   int cont;
-  int c;
   uint8_t *seen;
+  unsigned int optmatch = 0;
+  const char *have_exclusive = NULL;
 
   GNUNET_assert (argc > 0);
   GNoptind = 0;
@@ -890,12 +912,13 @@ GNUNET_GETOPT_run (const char *binaryOptions,
   clpc.allOptions = allOptions;
   clpc.argv = argv;
   clpc.argc = argc;
-  for (count = 0; NULL != allOptions[count].name; count++) ;
+  for (count = 0; NULL != allOptions[count].name; count++)
+    ;
 
-  long_options = GNUNET_new_array (count + 1,
-                                   struct GNoption);
-  seen = GNUNET_new_array (count,
-                           uint8_t);
+  /* transform our option representation into the format
+     used by the GNU getopt copylib */
+  long_options = GNUNET_new_array (count + 1, struct GNoption);
+  seen = GNUNET_new_array (count, uint8_t);
   shorts = GNUNET_malloc (count * 2 + 1);
   spos = 0;
   for (unsigned i = 0; i < count; i++)
@@ -916,59 +939,64 @@ GNUNET_GETOPT_run (const char *binaryOptions,
   cont = GNUNET_OK;
 
   /* main getopt loop */
-  while (GNUNET_OK == cont)
+  while (1)
   {
     int option_index = 0;
     unsigned int i;
+    int c;
 
-    c = GNgetopt_long (argc, argv,
-                       shorts,
-                       long_options,
-                       &option_index);
+    c = GNgetopt_long (argc, argv, shorts, long_options, &option_index);
     if (c == GNUNET_SYSERR)
-      break;                    /* No more flags to process */
+      break; /* No more flags to process */
 
+    /* Check which of our program's options was given by the user */
     for (i = 0; i < count; i++)
     {
       clpc.currentArgument = GNoptind - 1;
       if ((char) c == allOptions[i].shortName)
       {
-        cont = allOptions[i].processor (&clpc,
-                                        allOptions[i].scls,
-                                        allOptions[i].name,
-                                        GNoptarg);
+        optmatch++;
+        if (allOptions[i].option_exclusive)
+          have_exclusive = allOptions[i].name;
+        if (GNUNET_OK == cont)
+        {
+          /* parse the option using the option-specific processor */
+          cont = allOptions[i].processor (&clpc,
+                                          allOptions[i].scls,
+                                          allOptions[i].name,
+                                          GNoptarg);
+        }
         seen[i] = 1;
         break;
       }
     }
     if (i == count)
     {
-      FPRINTF (stderr,
-               _("Use %s to get a list of options.\n"),
-               "--help");
+      FPRINTF (stderr, _ ("Use %s to get a list of options.\n"), "--help");
       cont = GNUNET_SYSERR;
     }
   }
   GNUNET_free (shorts);
   GNUNET_free (long_options);
 
+  /* check that if any option that was marked as exclusive
+     is the only option that was provided */
+  if ((NULL != have_exclusive) && (optmatch > 1))
+  {
+    FPRINTF (stderr,
+             _ ("Option `%s' can't be used with other options.\n"),
+             have_exclusive);
+    cont = GNUNET_SYSERR;
+  }
   if (GNUNET_YES == cont)
   {
-    for (count = 0; NULL != allOptions[count].name; count++) 
+    /* check that all mandatory options are present */
+    for (count = 0; NULL != allOptions[count].name; count++)
     {
-      if (allOptions[count].option_exclusive)
-      {
-        FPRINTF (stderr,
-                 _("Option `%s' can't be used with other options.\n"),
-                 allOptions[count].name);
-        cont = GNUNET_SYSERR;
-      }
-
-      if ( (0 == seen[count]) &&
-           (allOptions[count].option_mandatory) )
+      if ((0 == seen[count]) && (allOptions[count].option_mandatory))
       {
         FPRINTF (stderr,
-                 _("Missing mandatory option `%s'.\n"),
+                 _ ("Missing mandatory option `%s'.\n"),
                  allOptions[count].name);
         cont = GNUNET_SYSERR;
       }
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 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
 
 
 /**
@@ -48,9 +48,7 @@ print_version (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
 
   (void) option;
   (void) value;
-  printf ("%s v%s\n",
-         ctx->binaryName,
-         version);
+  printf ("%s v%s\n", ctx->binaryName, version);
   return GNUNET_NO;
 }
 
@@ -64,14 +62,13 @@ print_version (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_version (const char *version)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  'v',
-    .name = "version",
-    .description = gettext_noop("print the version number"),
-    .option_exclusive = 1,
-    .processor = &print_version,
-    .scls = (void *) version
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'v',
+                                                .name = "version",
+                                                .description = gettext_noop (
+                                                  "print the version number"),
+                                                .option_exclusive = 1,
+                                                .processor = &print_version,
+                                                .scls = (void *) version};
   return clo;
 }
 
@@ -111,10 +108,9 @@ format_help (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   (void) value;
   if (NULL != about)
   {
-    printf ("%s\n%s\n",
-           ctx->binaryOptions,
-           gettext (about));
-    printf (_("Arguments mandatory for long options are also mandatory for 
short options.\n"));
+    printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
+    printf (_ (
+      "Arguments mandatory for long options are also mandatory for short 
options.\n"));
   }
   i = 0;
   opt = ctx->allOptions;
@@ -147,7 +143,7 @@ format_help (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
       trans = "";
     ml = strlen (trans);
     p = 0;
-OUTER:
+  OUTER:
     while (ml - p > 78 - slen)
     {
       for (j = p + 78 - slen; j > (int) p; j--)
@@ -199,13 +195,13 @@ OUTER:
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_help (const char *about)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName = 'h',
-    .name = "help",
-    .description = gettext_noop("print this help"),
-    .processor = format_help,
-    .scls = (void *) about
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'h',
+                                                .name = "help",
+                                                .description = gettext_noop (
+                                                  "print this help"),
+                                                .option_exclusive = 1,
+                                                .processor = format_help,
+                                                .scls = (void *) about};
 
   return clo;
 }
@@ -252,17 +248,15 @@ increment_value (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_increment_uint (char shortName,
-                                    const char *name,
-                                    const char *description,
-                                    unsigned int *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .description = description,
-    .processor = &increment_value,
-    .scls = (void *) val
-  };
+                                     const char *name,
+                                     const char *description,
+                                     unsigned int *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .description = description,
+                                                .processor = &increment_value,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -277,13 +271,12 @@ GNUNET_GETOPT_option_increment_uint (char shortName,
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_verbose (unsigned int *level)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName = 'V',
-    .name = "verbose",
-    .description = gettext_noop("be verbose"),
-    .processor = &increment_value,
-    .scls = (void *) level
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'V',
+                                                .name = "verbose",
+                                                .description =
+                                                  gettext_noop ("be verbose"),
+                                                .processor = &increment_value,
+                                                .scls = (void *) level};
 
   return clo;
 }
@@ -331,17 +324,15 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext 
*ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_flag (char shortName,
-                          const char *name,
-                          const char *description,
-                          int *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .description = description,
-    .processor = &set_one,
-    .scls = (void *) val
-  };
+                           const char *name,
+                           const char *description,
+                           int *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .description = description,
+                                                .processor = &set_one,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -394,15 +385,13 @@ GNUNET_GETOPT_option_string (char shortName,
                              const char *description,
                              char **str)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_string,
-    .scls = (void *) str
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_string,
+                                                .scls = (void *) str};
 
   return clo;
 }
@@ -417,15 +406,14 @@ GNUNET_GETOPT_option_string (char shortName,
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_loglevel (char **level)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName = 'L',
-    .name = "log",
-    .argumentHelp = "LOGLEVEL",
-    .description = gettext_noop("configure logging to use LOGLEVEL"),
-    .require_argument = 1,
-    .processor = &set_string,
-    .scls = (void *) level
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo =
+    {.shortName = 'L',
+     .name = "log",
+     .argumentHelp = "LOGLEVEL",
+     .description = gettext_noop ("configure logging to use LOGLEVEL"),
+     .require_argument = 1,
+     .processor = &set_string,
+     .scls = (void *) level};
 
   return clo;
 }
@@ -470,20 +458,18 @@ set_filename (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_filename (char shortName,
-                              const char *name,
-                              const char *argumentHelp,
-                              const char *description,
-                              char **str)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_filename,
-    .scls = (void *) str
-  };
+                               const char *name,
+                               const char *argumentHelp,
+                               const char *description,
+                               char **str)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_filename,
+                                                .scls = (void *) str};
 
   return clo;
 }
@@ -497,15 +483,15 @@ GNUNET_GETOPT_option_filename (char shortName,
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_logfile (char **logfn)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  'l',
-    .name = "logfile",
-    .argumentHelp = "FILENAME",
-    .description = gettext_noop ("configure logging to write logs to 
FILENAME"),
-    .require_argument = 1,
-    .processor = &set_filename,
-    .scls = (void *) logfn
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo =
+    {.shortName = 'l',
+     .name = "logfile",
+     .argumentHelp = "FILENAME",
+     .description =
+       gettext_noop ("configure logging to write logs to FILENAME"),
+     .require_argument = 1,
+     .processor = &set_filename,
+     .scls = (void *) logfn};
 
   return clo;
 }
@@ -519,15 +505,14 @@ GNUNET_GETOPT_option_logfile (char **logfn)
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_cfgfile (char **fn)
 {
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  'c',
-    .name = "config",
-    .argumentHelp = "FILENAME",
-    .description = gettext_noop("use configuration file FILENAME"),
-    .require_argument = 1,
-    .processor = &set_filename,
-    .scls = (void *) fn
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo =
+    {.shortName = 'c',
+     .name = "config",
+     .argumentHelp = "FILENAME",
+     .description = gettext_noop ("use configuration file FILENAME"),
+     .require_argument = 1,
+     .processor = &set_filename,
+     .scls = (void *) fn};
 
   return clo;
 }
@@ -556,13 +541,10 @@ set_ulong (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   char dummy[2];
 
   (void) ctx;
-  if (1 != SSCANF (value,
-                   "%llu%1s",
-                   val,
-                  dummy))
+  if (1 != SSCANF (value, "%llu%1s", val, dummy))
   {
     FPRINTF (stderr,
-             _("You must pass a number to the `%s' option.\n"),
+             _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
@@ -581,20 +563,18 @@ set_ulong (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_ulong (char shortName,
-                           const char *name,
-                           const char *argumentHelp,
-                           const char *description,
-                           unsigned long long *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_ulong,
-    .scls = (void *) val
-  };
+                            const char *name,
+                            const char *argumentHelp,
+                            const char *description,
+                            unsigned long long *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_ulong,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -620,14 +600,12 @@ set_relative_time (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
                    const char *value)
 {
   struct GNUNET_TIME_Relative *val = scls;
-  
-  (void) ctx;  
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_fancy_time_to_relative (value,
-                                            val))
+
+  (void) ctx;
+  if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (value, val))
   {
     FPRINTF (stderr,
-             _("You must pass relative time to the `%s' option.\n"),
+             _ ("You must pass relative time to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
@@ -647,20 +625,18 @@ set_relative_time (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_relative_time (char shortName,
-                                   const char *name,
-                                   const char *argumentHelp,
-                                   const char *description,
-                                   struct GNUNET_TIME_Relative *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_relative_time,
-    .scls = (void *) val
-  };
+                                    const char *name,
+                                    const char *argumentHelp,
+                                    const char *description,
+                                    struct GNUNET_TIME_Relative *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = 
&set_relative_time,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -688,12 +664,10 @@ set_absolute_time (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   struct GNUNET_TIME_Absolute *val = scls;
 
   (void) ctx;
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_fancy_time_to_absolute (value,
-                                            val))
+  if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (value, val))
   {
     FPRINTF (stderr,
-             _("You must pass absolute time to the `%s' option.\n"),
+             _ ("You must pass absolute time to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
@@ -713,20 +687,18 @@ set_absolute_time (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_absolute_time (char shortName,
-                                   const char *name,
-                                   const char *argumentHelp,
-                                   const char *description,
-                                   struct GNUNET_TIME_Absolute *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_absolute_time,
-    .scls = (void *) val
-  };
+                                    const char *name,
+                                    const char *argumentHelp,
+                                    const char *description,
+                                    struct GNUNET_TIME_Absolute *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = 
&set_absolute_time,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -755,20 +727,18 @@ set_uint (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   char dummy[2];
 
   (void) ctx;
-  if('-' == *value)
+  if ('-' == *value)
   {
-       FPRINTF (stderr,
-               _("Your input for the '%s' option has to be a non negative 
number \n"),
-               option);
-       return GNUNET_SYSERR;
+    FPRINTF (stderr,
+             _ (
+               "Your input for the '%s' option has to be a non negative number 
\n"),
+             option);
+    return GNUNET_SYSERR;
   }
-  if (1 != SSCANF (value,
-                   "%u%1s",
-                   val,
-                  dummy))
+  if (1 != SSCANF (value, "%u%1s", val, dummy))
   {
     FPRINTF (stderr,
-             _("You must pass a number to the `%s' option.\n"),
+             _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
@@ -787,26 +757,23 @@ set_uint (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_uint (char shortName,
-                          const char *name,
-                          const char *argumentHelp,
-                          const char *description,
-                          unsigned int *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_uint,
-    .scls = (void *) val
-  };
+                           const char *name,
+                           const char *argumentHelp,
+                           const char *description,
+                           unsigned int *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_uint,
+                                                .scls = (void *) val};
 
   return clo;
 }
 
 
-
 /**
  * Set an option of type 'uint16_t' from the command line.
  * A pointer to this function should be passed as part of the
@@ -822,30 +789,27 @@ GNUNET_GETOPT_option_uint (char shortName,
  */
 static int
 set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
-           void *scls,
-           const char *option,
-           const char *value)
+            void *scls,
+            const char *option,
+            const char *value)
 {
   uint16_t *val = scls;
   unsigned int v;
   char dummy[2];
-  
+
   (void) ctx;
-  if (1 != SSCANF (value,
-                   "%u%1s",
-                   &v,
-                  dummy))
+  if (1 != SSCANF (value, "%u%1s", &v, dummy))
   {
     FPRINTF (stderr,
-             _("You must pass a number to the `%s' option.\n"),
+             _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
   if (v > UINT16_MAX)
   {
     FPRINTF (stderr,
-             _("You must pass a number below %u to the `%s' option.\n"),
-            (unsigned int) UINT16_MAX,
+             _ ("You must pass a number below %u to the `%s' option.\n"),
+             (unsigned int) UINT16_MAX,
              option);
     return GNUNET_SYSERR;
   }
@@ -865,20 +829,18 @@ set_uint16 (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_uint16 (char shortName,
-                            const char *name,
-                            const char *argumentHelp,
-                            const char *description,
-                            uint16_t *val)
-{
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_uint16,
-    .scls = (void *) val
-  };
+                             const char *name,
+                             const char *argumentHelp,
+                             const char *description,
+                             uint16_t *val)
+{
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_uint16,
+                                                .scls = (void *) val};
 
   return clo;
 }
@@ -923,15 +885,16 @@ set_base32 (struct 
GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   struct Base32Context *bc = scls;
 
   (void) ctx;
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_string_to_data (value,
-                                     strlen (value),
-                                     bc->val,
-                                     bc->val_size))
+  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (value,
+                                                  strlen (value),
+                                                  bc->val,
+                                                  bc->val_size))
   {
-    fprintf (stderr,
-             _("Argument `%s' malformed. Expected base32 (Crockford) encoded 
value.\n"),
-             option);
+    fprintf (
+      stderr,
+      _ (
+        "Argument `%s' malformed. Expected base32 (Crockford) encoded 
value.\n"),
+      option);
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -964,23 +927,21 @@ free_bc (void *cls)
  */
 struct GNUNET_GETOPT_CommandLineOption
 GNUNET_GETOPT_option_base32_fixed_size (char shortName,
-                                            const char *name,
-                                            const char *argumentHelp,
-                                            const char *description,
-                                            void *val,
-                                            size_t val_size)
+                                        const char *name,
+                                        const char *argumentHelp,
+                                        const char *description,
+                                        void *val,
+                                        size_t val_size)
 {
   struct Base32Context *bc = GNUNET_new (struct Base32Context);
-  struct GNUNET_GETOPT_CommandLineOption clo = {
-    .shortName =  shortName,
-    .name = name,
-    .argumentHelp = argumentHelp,
-    .description = description,
-    .require_argument = 1,
-    .processor = &set_base32,
-    .cleaner = &free_bc,
-    .scls = (void *) bc
-  };
+  struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+                                                .name = name,
+                                                .argumentHelp = argumentHelp,
+                                                .description = description,
+                                                .require_argument = 1,
+                                                .processor = &set_base32,
+                                                .cleaner = &free_bc,
+                                                .scls = (void *) bc};
 
   bc->val = val;
   bc->val_size = val_size;
@@ -1002,4 +963,18 @@ GNUNET_GETOPT_option_mandatory (struct 
GNUNET_GETOPT_CommandLineOption opt)
 }
 
 
+/**
+ * Make the given option mutually exclusive with other options.
+ *
+ * @param opt option to modify
+ * @return @a opt with the exclusive flag set.
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt)
+{
+  opt.option_exclusive = 1;
+  return opt;
+}
+
+
 /* 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,
       fn = value_fn;
     else
       GNUNET_free (value_fn);
-    fprintf (stdout,
-             "%s = %s\n",
-             option,
-             fn);
+    fprintf (stdout, "%s = %s\n", option, fn);
     GNUNET_free (fn);
   }
   else
   {
-    fprintf (stdout,
-             "%s = %s\n",
-             option,
-             value);
+    fprintf (stdout, "%s = %s\n", option, value);
   }
 }
 
@@ -126,13 +120,10 @@ print_option (void *cls,
  * @param section a section in the configuration file
  */
 static void
-print_section_name (void *cls,
-                    const char *section)
+print_section_name (void *cls, const char *section)
 {
   (void) cls;
-  fprintf (stdout,
-           "%s\n",
-           section);
+  fprintf (stdout, "%s\n", section);
 }
 
 
@@ -161,9 +152,7 @@ run (void *cls,
   {
     char *name;
 
-    GNUNET_asprintf (&name,
-                    "libgnunet_plugin_%s",
-                    backend_check);
+    GNUNET_asprintf (&name, "libgnunet_plugin_%s", backend_check);
     global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77;
     GNUNET_free (name);
     return;
@@ -173,40 +162,34 @@ run (void *cls,
     struct GNUNET_CONFIGURATION_Handle *def;
 
     def = GNUNET_CONFIGURATION_create ();
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_load (def, NULL))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_load (def, NULL))
     {
-      fprintf (stderr,
-               _("failed to load configuration defaults"));
+      fprintf (stderr, _ ("failed to load configuration defaults"));
       global_ret = 1;
       return;
     }
-    diff = GNUNET_CONFIGURATION_get_diff (def,
-                                          cfg);
+    diff = GNUNET_CONFIGURATION_get_diff (def, cfg);
     cfg = diff;
   }
-  if ( ((! rewrite) && (NULL == section)) || list_sections)
+  if (((! rewrite) && (NULL == section)) || list_sections)
   {
     if (! list_sections)
     {
       fprintf (stderr,
-               _("%s or %s argument is required\n"),
+               _ ("%s or %s argument is required\n"),
                "--section",
                "--list-sections");
       global_ret = 1;
     }
     else
     {
-      fprintf (stderr,
-               _("The following sections are available:\n"));
-      GNUNET_CONFIGURATION_iterate_sections (cfg,
-                                             &print_section_name,
-                                             NULL);
+      fprintf (stderr, _ ("The following sections are available:\n"));
+      GNUNET_CONFIGURATION_iterate_sections (cfg, &print_section_name, NULL);
     }
     goto cleanup;
   }
 
-  if ( (NULL != section) && (NULL == value) )
+  if ((NULL != section) && (NULL == value))
   {
     if (NULL == option)
     {
@@ -219,26 +202,24 @@ run (void *cls,
     {
       if (is_filename)
       {
-        if (GNUNET_OK !=
-            GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                     section,
-                                                     option,
-                                                     &value))
+        if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                                  section,
+                                                                  option,
+                                                                  &value))
         {
-          GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                                     section, option);
+          GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
           global_ret = 3;
           goto cleanup;
         }
       }
       else
       {
-        if (GNUNET_OK !=
-            GNUNET_CONFIGURATION_get_value_string (cfg, section,
-                                                   option, &value))
+        if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                                section,
+                                                                option,
+                                                                &value))
         {
-          GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                                     section, option);
+          GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
           global_ret = 3;
           goto cleanup;
         }
@@ -250,15 +231,12 @@ run (void *cls,
   {
     if (NULL == option)
     {
-      fprintf (stderr, _("--option argument required to set value\n"));
+      fprintf (stderr, _ ("--option argument required to set value\n"));
       global_ret = 1;
       goto cleanup;
     }
     out = GNUNET_CONFIGURATION_dup (cfg);
-    GNUNET_CONFIGURATION_set_value_string (out,
-                                           section,
-                                           option,
-                                           value);
+    GNUNET_CONFIGURATION_set_value_string (out, section, option, value);
   }
   cfg_fn = NULL;
   if (NULL == cfgfile)
@@ -274,11 +252,10 @@ run (void *cls,
       cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
     cfgfile = cfg_fn;
   }
-  if ( (NULL != diff) || (NULL != out) )
+  if ((NULL != diff) || (NULL != out))
   {
     if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out,
-                                    cfgfile))
+        GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, cfgfile))
       global_ret = 2;
   }
   GNUNET_free_non_null (cfg_fn);
@@ -298,62 +275,66 @@ cleanup:
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('f',
-      "filename",
-      gettext_noop ("interpret option value as a filename (with $-expansion)"),
-      &is_filename),
-    //GNUNET_GETOPT_option_exclusive
-    (GNUNET_GETOPT_option_string ('b',
-                                "supported-backend",
-                                 "BACKEND",
-                                 gettext_noop ("test if the current 
installation supports the specified BACKEND"),
-                                 &backend_check)),
-    GNUNET_GETOPT_option_string ('s',
-                                "section",
-                                "SECTION",
-                                gettext_noop ("name of the section to access"),
-                                &section),
-    GNUNET_GETOPT_option_string ('o',
-                                 "option",
-                                 "OPTION",
-                                 gettext_noop ("name of the option to access"),
-                                 &option),
-    GNUNET_GETOPT_option_string ('V',
-                                 "value",
-                                 "VALUE",
-                                 gettext_noop ("value to set"),
-                                 &value),
-    GNUNET_GETOPT_option_flag ('S',
-                       "list-sections",
-                       gettext_noop ("print available configuration sections"),
-                       &list_sections),
-    GNUNET_GETOPT_option_flag ('w',
-                               "rewrite",
-                               gettext_noop ("write configuration file that 
only contains delta to defaults"),
-                               &rewrite),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag (
+       'f',
+       "filename",
+       gettext_noop ("interpret option value as a filename (with 
$-expansion)"),
+       &is_filename),
+     GNUNET_GETOPT_option_exclusive (GNUNET_GETOPT_option_string (
+       'b',
+       "supported-backend",
+       "BACKEND",
+       gettext_noop (
+         "test if the current installation supports the specified BACKEND"),
+       &backend_check)),
+     GNUNET_GETOPT_option_string ('s',
+                                  "section",
+                                  "SECTION",
+                                  gettext_noop (
+                                    "name of the section to access"),
+                                  &section),
+     GNUNET_GETOPT_option_string ('o',
+                                  "option",
+                                  "OPTION",
+                                  gettext_noop ("name of the option to 
access"),
+                                  &option),
+     GNUNET_GETOPT_option_string ('V',
+                                  "value",
+                                  "VALUE",
+                                  gettext_noop ("value to set"),
+                                  &value),
+     GNUNET_GETOPT_option_flag ('S',
+                                "list-sections",
+                                gettext_noop (
+                                  "print available configuration sections"),
+                                &list_sections),
+     GNUNET_GETOPT_option_flag (
+       'w',
+       "rewrite",
+       gettext_noop (
+         "write configuration file that only contains delta to defaults"),
+       &rewrite),
+     GNUNET_GETOPT_OPTION_END};
   int ret;
-         
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                    &argc, &argv))
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  ret = GNUNET_PROGRAM_run (argc,
-                           argv,
-                           "gnunet-config [OPTIONS]",
-                           gettext_noop ("Manipulate GNUnet configuration 
files"),
-                           options,
-                           &run, NULL);
-  GNUNET_free ((void*) argv);
+  ret =
+    GNUNET_PROGRAM_run (argc,
+                        argv,
+                        "gnunet-config [OPTIONS]",
+                        gettext_noop ("Manipulate GNUnet configuration files"),
+                        options,
+                        &run,
+                        NULL);
+  GNUNET_free ((void *) argv);
   if (GNUNET_OK == ret)
     return global_ret;
-  return 1;
+  return ret;
 }
 
 /* end of gnunet-config.c */

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]