Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / util / getopt.c
index c37272442068dea62f8abe3efc494310607e8094..ff62dba9be0fae2d9fee7fb95917253da5f8264e 100644 (file)
@@ -3,7 +3,7 @@
    "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
    before changing it!
 
-   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
+   Copyright Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
      Free Software Foundation, Inc.
 
 NOTE: The canonical source of this file is maintained with the GNU C Library.
@@ -11,7 +11,7 @@ Bugs can be reported to bug-glibc@prep.ai.mit.edu.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
+Free Software Foundation; either version 3, or (at your option) any
 later version.
 
 This program is distributed in the hope that it will be useful,
@@ -21,12 +21,12 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 USA.
 
 
 This code was heavily modified for GNUnet.
-Copyright (C) 2006 Christian Grothoff
+Copyright Copyright (C) 2006 Christian Grothoff
 */
 
 /**
@@ -37,10 +37,8 @@ Copyright (C) 2006 Christian Grothoff
  * replace main GNU getopt parser with one that
  * actually fits our API.
  */
-
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_getopt_lib.h"
+#include "gnunet_util_lib.h"
 
 #ifdef VMS
 #include <unixlib.h>
@@ -49,9 +47,9 @@ Copyright (C) 2006 Christian Grothoff
 #endif
 #endif
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
+#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-getopt", syscall)
 
 #if defined (WIN32) && !defined (__CYGWIN32__)
 /* It's not Unix, really.  See?  Capital letters.  */
@@ -351,7 +349,7 @@ _getopt_initialize (int argc,
 
   return optstring;
 }
-\f
+
 /* Scan elements of ARGV (whose length is ARGC) for option characters
    given in OPTSTRING.
 
@@ -767,8 +765,7 @@ 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 '?';
@@ -940,8 +937,10 @@ GNUNET_GETOPT_run (const char *binaryOptions,
 
   GNUNET_free (shorts);
   GNUNET_free (long_options);
-  if (cont == GNUNET_SYSERR)
-    return GNUNET_SYSERR;
+  if (cont != GNUNET_OK)
+  {
+    return cont;
+  }
   return GNoptind;
 }