Code

Imported upstream version 1.3.5.
[pkg-rrdtool.git] / src / rrd_getopt.c
index 50a61e882ea76d13104285a6b30d9af92adff995..57266302db8ac849b9826836e9b3bfdbc2dac511 100644 (file)
@@ -30,6 +30,8 @@
 #define _NO_PROTO
 #endif
 
+#ifndef WIN32
+
 #if !defined (__STDC__) || !__STDC__
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
@@ -38,6 +40,7 @@
 #endif
 #endif
 
+#endif // WIN32
 
 #ifdef HAVE_CONFIG_H
 #include "../rrd_config.h"
@@ -207,11 +210,15 @@ static char *posixly_correct;
 char     *getenv(
     );
 
+#ifdef WIN32
+static char* my_index(const char* str, int chr)
+#else // WIN32
 static char *my_index(
     str,
     chr)
     const char *str;
     int chr;
+#endif // wIN32
 {
     while (*str) {
         if (*str == chr)
@@ -288,9 +295,13 @@ static void exchange(
     char **);
 #endif
 
+#ifdef WIN32
+static void exchange(char** argv)
+#else // WIN32
 static void exchange(
     argv)
     char    **argv;
+#endif // WIN32
 {
     int       bottom = first_nonopt;
     int       middle = last_nonopt;
@@ -346,6 +357,12 @@ static const char *_getopt_initialize(
     char *const *,
     const char *);
 #endif
+
+#ifdef WIN32
+static const char* _getopt_initialize(int argc,
+                                      char** argv,
+                                      const char* optstring)
+#else // WIN32
 static const char *_getopt_initialize(
     argc,
     argv,
@@ -353,6 +370,7 @@ static const char *_getopt_initialize(
     int argc;
     char     *const *argv;
     const char *optstring;
+#endif // WIN32
 {
     /* Start processing options with ARGV-element 1 (since ARGV-element 0
        is the program name); the sequence of previously skipped
@@ -455,6 +473,14 @@ static const char *_getopt_initialize(
    If LONG_ONLY is nonzero, '-' as well as '--' can introduce
    long-named options.  */
 
+#ifdef WIN32
+int _getopt_internal(int argc,
+                     char** argv,
+                     const char *optstring,
+                     const struct option *longopts,
+                     int* longind,
+                     int long_only)
+#else // WIN32
 int _getopt_internal(
     argc,
     argv,
@@ -468,6 +494,7 @@ int _getopt_internal(
     const struct option *longopts;
     int      *longind;
     int long_only;
+#endif // WIN32
 {
     optarg = NULL;
 
@@ -867,6 +894,12 @@ int _getopt_internal(
     }
 }
 
+#ifdef WIN32
+int getopt(
+    int argc,
+    char** argv,
+    const char* optstring)
+#else // WIN32
 int getopt(
     argc,
     argv,
@@ -874,6 +907,7 @@ int getopt(
     int argc;
     char     *const *argv;
     const char *optstring;
+#endif // WIN32
 {
     return _getopt_internal(argc, argv, optstring,
                             (const struct option *) 0, (int *) 0, 0);