]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/getopt.c
Use new macros from configure.in to accomodate NT/Mingw32 environment.
[openldap] / libraries / liblutil / getopt.c
index 112616fdceb4b717850c422831cf7eb5eb7190fc..ac63dbdae4d9240ae647c24dada2f542cc7342a1 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
        getopt.c
 
 #include <ac/string.h>
 #include <ac/unistd.h>
 
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
 int opterr = 1;
 int optind = 1;
 int optopt;
 char * optarg;
 
-static void ERR (char ** argv, char * s, char c)
+static void ERR (char * const argv[], const char * s, char c)
 {
        char errbuf[2];
 
@@ -36,7 +49,7 @@ printf("DF_TRACE_DEBUG:       static void ERR () in getopt.c\n");
        }
 }
 
-int getopt (int argc, char ** argv, char * opts)
+int getopt (int argc, char * const argv [], const char * opts)
 {
        static int sp = 1, error = (int) '?';
        static char sw = '-', eos = '\0', arg = ':';
@@ -46,6 +59,7 @@ int getopt (int argc, char ** argv, char * opts)
 printf("DF_TRACE_DEBUG:        int getopt () in getopt.c\n");
 #endif
        if (sp == 1)
+       {
                if (optind >= argc || argv[optind][0] != sw
                || argv[optind][1] == eos)
                        return EOF;
@@ -54,6 +68,7 @@ printf("DF_TRACE_DEBUG:       int getopt () in getopt.c\n");
                        optind++;
                        return EOF;
                }
+       }
        c = argv[optind][sp];
        optopt = (int) c;
        if (c == arg || (cp = strchr(opts,c)) == NULL)