27 #if !defined __STDC__ || !__STDC__ 45 #define GETOPT_INTERFACE_VERSION 2 46 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 47 #include <gnu-versions.h> 48 #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION 58 #ifdef __GNU_LIBRARY__ 67 getopt_long (argc, argv, options, long_options, opt_index)
71 const struct option *long_options;
74 return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
83 getopt_long_only (argc, argv, options, long_options, opt_index)
87 const struct option *long_options;
90 return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
106 int digit_optind = 0;
110 int this_option_optind = optind ? optind : 1;
111 int option_index = 0;
112 static struct option long_options[] =
117 {
"verbose", 0, 0, 0},
123 c = getopt_long (argc, argv,
"abc:d:0123456789",
124 long_options, &option_index);
131 printf (
"option %s", long_options[option_index].name);
133 printf (
" with arg %s", optarg);
147 if (digit_optind != 0 && digit_optind != this_option_optind)
148 printf (
"digits occur in two different argv-elements.\n");
149 digit_optind = this_option_optind;
150 printf (
"option %c\n", c);
154 printf (
"option a\n");
158 printf (
"option b\n");
162 printf (
"option c with value `%s'\n", optarg);
166 printf (
"option d with value `%s'\n", optarg);
173 printf (
"?? getopt returned character code 0%o ??\n", c);
179 printf (
"non-option ARGV-elements: ");
180 while (optind < argc)
181 printf (
"%s ", argv[optind++]);
int main(int argc, char *argv[])