PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_getopt.h
Go to the documentation of this file.
1 /*
2  * Portions Copyright (c) 1987, 1993, 1994
3  * The Regents of the University of California. All rights reserved.
4  *
5  * Portions Copyright (c) 2003-2017, PostgreSQL Global Development Group
6  *
7  * src/include/pg_getopt.h
8  */
9 #ifndef PG_GETOPT_H
10 #define PG_GETOPT_H
11 
12 /* POSIX says getopt() is provided by unistd.h */
13 #include <unistd.h>
14 
15 /* rely on the system's getopt.h if present */
16 #ifdef HAVE_GETOPT_H
17 #include <getopt.h>
18 #endif
19 
20 /*
21  * If we have <getopt.h>, assume it declares these variables, else do that
22  * ourselves. (We used to just declare them unconditionally, but Cygwin
23  * doesn't like that.)
24  */
25 #ifndef HAVE_GETOPT_H
26 
27 extern char *optarg;
28 extern int optind;
29 extern int opterr;
30 extern int optopt;
31 
32 #endif /* HAVE_GETOPT_H */
33 
34 /*
35  * Some platforms have optreset but fail to declare it in <getopt.h>, so cope.
36  * Cygwin, however, doesn't like this either.
37  */
38 #if defined(HAVE_INT_OPTRESET) && !defined(__CYGWIN__)
39 extern int optreset;
40 #endif
41 
42 #ifndef HAVE_GETOPT
43 extern int getopt(int nargc, char *const *nargv, const char *ostr);
44 #endif
45 
46 #endif /* PG_GETOPT_H */
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:72
int optind
Definition: getopt.c:51
int optopt
Definition: getopt.c:51
int opterr
Definition: getopt.c:50
char * optarg
Definition: getopt.c:53