40 #define GETOPT_INTERFACE_VERSION 2
41 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
42 #include <gnu-versions.h>
43 #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
53 #ifdef __GNU_LIBRARY__
62 getopt_long (
int argc,
char *
const *argv,
const char *options,
63 const struct option *long_options,
int *opt_index)
65 return _getopt_internal (argc, argv, options, long_options, opt_index, 0, 0);
70 const struct option *long_options,
int *opt_index,
84 const struct option *long_options,
int *opt_index)
86 return _getopt_internal (argc, argv, options, long_options, opt_index, 1, 0);
91 const struct option *long_options,
int *opt_index,
105 main (
int argc,
char **argv)
108 int digit_optind = 0;
113 int option_index = 0;
114 static struct option long_options[] =
119 {
"verbose", 0, 0, 0},
126 long_options, &option_index);
133 printf (
"option %s", long_options[option_index].
name);
135 printf (
" with arg %s",
optarg);
149 if (digit_optind != 0 && digit_optind != this_option_optind)
150 printf (
"digits occur in two different argv-elements.\n");
151 digit_optind = this_option_optind;
152 printf (
"option %c\n", c);
156 printf (
"option a\n");
160 printf (
"option b\n");
164 printf (
"option c with value `%s'\n",
optarg);
168 printf (
"option d with value `%s'\n",
optarg);
175 printf (
"?? getopt returned character code 0%o ??\n", c);
181 printf (
"non-option ARGV-elements: ");
183 printf (
"%s ", argv[
optind++]);
int main(int argc, char **argv)
int getopt_long_only(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
int _getopt_long_only_r(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d)
int _getopt_long_r(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d)
int _getopt_internal(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only, int posixly_correct)
int _getopt_internal_r(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only, struct _getopt_data *d, int posixly_correct)