diff --git a/src/rrd_getopt.c b/src/rrd_getopt.c
index 50a61e882ea76d13104285a6b30d9af92adff995..d206af0bf62e84242099dedaf2c14c925525606a 100644 (file)
--- a/src/rrd_getopt.c
+++ b/src/rrd_getopt.c
#define _NO_PROTO
#endif
+#ifndef WIN32
+
#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#endif
#endif
+#endif // WIN32
#ifdef HAVE_CONFIG_H
#include "../rrd_config.h"
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
+/*
+ * On some versions of Solaris, opterr and friends are defined in core libc
+ * rather than in a separate getopt module. Define these variables only
+ * if configure found they aren't there by default. (We assume that testing
+ * opterr is sufficient for all of these except optreset.)
+ */
+#ifndef HAVE_INT_OPTERR
+
char *optarg = NULL;
/* Index in ARGV of the next element to be scanned.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
/* 1003.2 says this must be 1 before any call. */
int optind = 1;
+#else
+ extern int opterr;
+ extern int optind;
+ extern int optopt;
+ extern char *optarg;
+#endif
+
+
/* Formerly, initialization of getopt depended on optind==0, which
causes problems with re-calling getopt as programs generally don't
know that. */
static char *nextchar;
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
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)
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;
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,
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
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,
const struct option *longopts;
int *longind;
int long_only;
+#endif // WIN32
{
optarg = NULL;
}
}
+#ifdef WIN32
+int getopt(
+ int argc,
+ char** argv,
+ const char* optstring)
+#else // WIN32
int getopt(
argc,
argv,
int argc;
char *const *argv;
const char *optstring;
+#endif // WIN32
{
return _getopt_internal(argc, argv, optstring,
(const struct option *) 0, (int *) 0, 0);