*/
#include "postgres_fe.h"
-#include
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-
-extern char *optarg;
-
#include "libpq-fe.h"
+#include "pg_getopt.h"
/* an extensible array to keep track of elements to show */
typedef struct
#include
#include
#include
-
-#ifndef WIN32
#include
-#include
-
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-#else /* WIN32 */
-extern int getopt(int argc, char *const argv[], const char *optstring);
-#endif /* ! WIN32 */
-extern char *optarg;
-extern int optind;
+#include "pg_getopt.h"
const char *progname;
#include
#include
#include
-
-#ifdef WIN32
-int getopt(int argc, char *const argv[], const char *optstring);
-#else
#include
-#include
-
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-#endif /* ! WIN32 */
-extern char *optarg;
-extern int optind;
+#include "pg_getopt.h"
const char *progname;
#include "postgres_fe.h"
#include "miscadmin.h"
+#include "getopt_long.h"
#include "pg_upgrade.h"
-#include
#include
#include
#include
#include
#include
#include
-
-#ifndef WIN32
#include
-#include
-#endif /* ! WIN32 */
-
#ifdef HAVE_SYS_SELECT_H
#include
#endif
static int pthread_join(pthread_t th, void **thread_return);
#endif
-extern char *optarg;
-extern int optind;
-
/********************************************************************
* some configurable parameters */
#endif
#include "libpq-fe.h"
+#include "pg_getopt.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define BUFSIZE 1024
-extern char *optarg;
-extern int optind,
- opterr;
-
enum trivalue
{
TRI_DEFAULT,
#include
#include
#include
-#ifdef HAVE_GETOPT_H
-#include
-#endif
#include "access/htup_details.h"
#include "bootstrap/bootstrap.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
+#include "pg_getopt.h"
#include "postmaster/bgwriter.h"
#include "postmaster/startup.h"
#include "postmaster/walwriter.h"
#include "utils/relmapper.h"
#include "utils/tqual.h"
-extern int optind;
-extern char *optarg;
-
uint32 bootstrap_data_checksum_version = 0; /* No checksum */
#include
#endif
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-
#ifdef USE_BONJOUR
#include
#endif
#include "libpq/libpq.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
+#include "pg_getopt.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker_internals.h"
static unsigned int random_seed = 0;
static struct timeval random_start_time;
-extern char *optarg;
-extern int optind,
- opterr;
-
-#ifdef HAVE_INT_OPTRESET
-extern int optreset; /* might not be declared by system headers */
-#endif
-
#ifdef USE_BONJOUR
static DNSServiceRef bonjour_sdref = NULL;
#endif
#include
#include
#endif
-#ifdef HAVE_GETOPT_H
-#include
-#endif
#ifndef HAVE_GETRUSAGE
#include "rusagestub.h"
#include "pg_trace.h"
#include "parser/analyze.h"
#include "parser/parser.h"
+#include "pg_getopt.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "replication/walsender.h"
#include "mb/pg_wchar.h"
-extern char *optarg;
-extern int optind;
-
-#ifdef HAVE_INT_OPTRESET
-extern int optreset; /* might not be declared by system headers */
-#endif
-
-
/* ----------------
* global variables
* ----------------
#include "dumputils.h"
#include "parallel.h"
-extern char *optarg;
-extern int optind,
- opterr;
-
typedef struct
{
#include "pg_backup_utils.h"
#include "dumputils.h"
#include "parallel.h"
+#include "getopt_long.h"
#include
#include
#endif
-#include
-
-#include "getopt_long.h"
-
-extern char *optarg;
-extern int optind;
-
#ifdef ENABLE_NLS
#include
#endif
#include
#include
#include
-#ifdef HAVE_GETOPT_H
-#include
-#endif
#include "access/transam.h"
#include "access/tuptoaster.h"
#include "catalog/catversion.h"
#include "catalog/pg_control.h"
#include "common/fe_memutils.h"
-
-extern int optind;
-extern char *optarg;
+#include "pg_getopt.h"
static ControlFileData ControlFile; /* pg_control values */
};
int optindex;
- extern char *optarg;
- extern int optind;
int c;
memset(options, 0, sizeof *options);
#ifndef GETOPT_LONG_H
#define GETOPT_LONG_H
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-
-/* These are picked up from the system's getopt() facility. */
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern char *optarg;
+#include "pg_getopt.h"
#ifndef HAVE_STRUCT_OPTION
--- /dev/null
+/*
+ * Portions Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Portions Copyright (c) 2003-2014, PostgreSQL Global Development Group
+ *
+ * src/include/pg_getopt.h
+ */
+#ifndef PG_GETOPT_H
+#define PG_GETOPT_H
+
+/* POSIX says getopt() is provided by unistd.h */
+#include
+
+/* rely on the system's getopt.h if present */
+#ifdef HAVE_GETOPT_H
+#include
+#endif
+
+/*
+ * If we have , assume it declares these variables, else do that
+ * ourselves. (We used to just declare them unconditionally, but Cygwin
+ * doesn't like that.)
+ */
+#ifndef HAVE_GETOPT_H
+
+extern char *optarg;
+extern int optind;
+extern int opterr;
+extern int optopt;
+
+#ifdef HAVE_INT_OPTRESET
+extern int optreset;
+#endif
+
+#endif /* HAVE_GETOPT_H */
+
+#ifndef HAVE_GETOPT
+extern int getopt(int nargc, char *const * nargv, const char *ostr);
+#endif
+
+#endif /* PG_GETOPT_H */
#define ftello(a) ftell(a)
#endif
-#ifndef HAVE_GETOPT
-extern int getopt(int nargc, char *const * nargv, const char *ostr);
-#endif
-
#if !defined(HAVE_GETPEEREID) && !defined(WIN32)
extern int getpeereid(int sock, uid_t *uid, gid_t *gid);
#endif
#include "c.h"
+#include "pg_getopt.h"
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
optind = 1, /* index into parent argv vector */
optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
-#else
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern char *optarg;
#endif
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
-int getopt(int nargc, char *const * nargv, const char *ostr);
-
/*
* getopt
* Parse argc/argv argument vector.
#ifdef WIN32
#include
#endif
-
-#ifndef WIN32
#include
-#include
-
-#ifdef HAVE_GETOPT_H
-#include
-#endif
-#else
-int getopt(int argc, char *const argv[], const char *optstring);
-#endif /* ! WIN32 */
-
#ifdef HAVE_SYS_SELECT_H
#include
#endif
#include "libpq-fe.h"
#include "pqexpbuffer.h"
+#include "pg_getopt.h"
#include "isolationtester.h"
-extern int optind;
-
#define PREP_WAITING "isolationtester_waiting"
/*
#include "postgres_fe.h"
-#ifdef HAVE_GETOPT_H
-#include
-#endif
#include
#include
#include
-extern int optind;
-extern char *optarg;
+#include "pg_getopt.h"
#include "private.h"
#include "pgtz.h"