#ifndef _GETOPT_H
#define _GETOPT_H 1
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
- extern char *optarg;
+ extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
- extern int optind;
+ extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
- extern int opterr;
+ extern int opterr;
/* Set to an option character which was unrecognized. */
- extern int optopt;
+ extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
- struct option
- {
+ struct option
+ {
#if defined (__STDC__) && __STDC__
- const char *name;
+ const char *name;
#else
- char *name;
+ char *name;
#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
- };
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+ };
/* Names for the values of the `has_arg' field of `struct option'. */
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
- extern int getopt(int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
- extern int getopt();
-#endif /* __GNU_LIBRARY__ */
- extern int getopt_long(int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
- extern int getopt_long_only(int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
+ extern int getopt(int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
+ extern int getopt();
+#endif /* __GNU_LIBRARY__ */
+ extern int getopt_long(int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+ extern int getopt_long_only(int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
- extern int _getopt_internal(int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
- extern int getopt();
- extern int getopt_long();
- extern int getopt_long_only();
-
- extern int _getopt_internal();
-#endif /* __STDC__ */
-
-#ifdef __cplusplus
+ extern int _getopt_internal(int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+#else /* not __STDC__ */
+ extern int getopt();
+ extern int getopt_long();
+ extern int getopt_long_only();
+
+ extern int _getopt_internal();
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
}
#endif
-#endif /* _GETOPT_H */
+#endif /* _GETOPT_H */