pg_getopt.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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-2016, PostgreSQL Global Development Group
  6. *
  7. * src/include/pg_getopt.h
  8. */
  9. #ifndef PG_GETOPT_H
  10. #define PG_GETOPT_H
  11. /* POSIX says getopt() is provided by unistd.h */
  12. #include <unistd.h>
  13. /* rely on the system's getopt.h if present */
  14. #ifdef HAVE_GETOPT_H
  15. #include <getopt.h>
  16. #endif
  17. /*
  18. * If we have <getopt.h>, assume it declares these variables, else do that
  19. * ourselves. (We used to just declare them unconditionally, but Cygwin
  20. * doesn't like that.)
  21. */
  22. #ifndef HAVE_GETOPT_H
  23. extern char *optarg;
  24. extern int optind;
  25. extern int opterr;
  26. extern int optopt;
  27. #endif /* HAVE_GETOPT_H */
  28. /*
  29. * Some platforms have optreset but fail to declare it in <getopt.h>, so cope.
  30. * Cygwin, however, doesn't like this either.
  31. */
  32. #if defined(HAVE_INT_OPTRESET) && !defined(__CYGWIN__)
  33. extern int optreset;
  34. #endif
  35. #ifndef HAVE_GETOPT
  36. extern int getopt(int nargc, char *const * nargv, const char *ostr);
  37. #endif
  38. #endif /* PG_GETOPT_H */