xapian-core  2.0.0
getopt.cc
Go to the documentation of this file.
1 /* Getopt for GNU.
2  NOTE: getopt is now part of the C library, so if you don't know what
3  "Keep this file name-space clean" means, talk to drepper@gnu.org
4  before changing it!
5 
6  Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
7  Free Software Foundation, Inc.
8  Copyright (C) 2004,2009,2010,2015 Olly Betts (reworked to allow compilation as C++)
9 
10  The GNU C Library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public
12  License as published by the Free Software Foundation; either
13  version 2 of the License, or (at your option) any later version.
14 
15  The GNU C Library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Library General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public
21  License along with this library; see the file COPYING.LIB. If not, see
22  <https://www.gnu.org/licenses/>. */
23 ␌
24 
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include "gnu_getopt.h"
30 
31 /* #ifdef out all this code if we are using the GNU C Library. GNU getopt
32  is included in the GNU C Library, and linking in this code is a waste when
33  using the GNU C library (especially if it is a shared library). */
34 
35 #ifndef USE_GLIBC_GNUGETOPT
36 
37 #include <cstdio>
38 
39 using std::fprintf;
40 
41 #ifdef VMS
42 # include <unixlib.h>
43 #endif
44 
45 #ifndef _
46 /* This is for other GNU distributions with internationalized messages. */
47 # if 0 //defined HAVE_LIBINTL_H || defined _LIBC
48 # include <libintl.h>
49 # ifndef _
50 # define _(msgid) gettext (msgid)
51 # endif
52 # else
53 # define _(msgid) (msgid)
54 # endif
55 #endif
56 
57 #ifndef __CYGWIN__
58 /* This version of `getopt' appears to the caller like standard Unix `getopt'
59  but it behaves differently for the user, since it allows the user
60  to intersperse the options with the other arguments.
61 
62  As `getopt' works, it permutes the elements of ARGV so that,
63  when it is done, all the options precede everything else. Thus
64  all application programs are extended to handle flexible argument order.
65 
66  Setting the environment variable POSIXLY_CORRECT disables permutation.
67  Then the behavior is completely standard.
68 
69  GNU application programs can use a third alternative mode in which
70  they can distinguish the relative order of options and other arguments. */
71 
72 /* For communication from `getopt' to the caller.
73  When `getopt' finds an option that takes an argument,
74  the argument value is returned here.
75  Also, when `ordering' is RETURN_IN_ORDER,
76  each non-option ARGV-element is returned here. */
77 
78 char *optarg;
79 
80 /* Index in ARGV of the next element to be scanned.
81  This is used for communication to and from the caller
82  and for communication between successive calls to `getopt'.
83 
84  On entry to `getopt', zero means this is the first call; initialize.
85 
86  When `getopt' returns -1, this is the index of the first of the
87  non-option elements that the caller should itself scan.
88 
89  Otherwise, `optind' communicates from one call to the next
90  how much of ARGV has been scanned so far. */
91 
92 /* 1003.2 says this must be 1 before any call. */
93 int optind = 1;
94 
95 /* Callers store zero here to inhibit the error message
96  for unrecognized options. */
97 
98 int opterr = 1;
99 
100 /* Set to an option character which was unrecognized.
101  This must be initialized on some systems to avoid linking in the
102  system's own getopt implementation. */
103 
104 int optopt = '?';
105 #endif
106 
107 /* Formerly, initialization of getopt depended on optind==0, which
108  causes problems with re-calling getopt as programs generally don't
109  know that. */
110 
112 
113 /* The next char to be scanned in the option-element
114  in which the last option character we returned was found.
115  This allows us to pick up the scan where we left off.
116 
117  If this is zero, or a null string, it means resume the scan
118  by advancing to the next ARGV-element. */
119 
120 static char *nextchar;
121 
122 /* Describe how to deal with options that follow non-option ARGV-elements.
123 
124  If the caller did not specify anything,
125  the default is REQUIRE_ORDER if the environment variable
126  POSIXLY_CORRECT is defined, PERMUTE otherwise.
127 
128  REQUIRE_ORDER means don't recognize them as options;
129  stop option processing when the first non-option is seen.
130  This is what Unix does.
131  This mode of operation is selected by either setting the environment
132  variable POSIXLY_CORRECT, or using `+' as the first character
133  of the list of option characters.
134 
135  PERMUTE is the default. We permute the contents of ARGV as we scan,
136  so that eventually all the non-options are at the end. This allows options
137  to be given in any order, even with programs that were not written to
138  expect this.
139 
140  RETURN_IN_ORDER is an option available to programs that were written
141  to expect options and other ARGV-elements in any order and that care about
142  the ordering of the two. We describe each non-option ARGV-element
143  as if it were the argument of an option with character code 1.
144  Using `-' as the first character of the list of option characters
145  selects this mode of operation.
146 
147  The special argument `--' forces an end of option-scanning regardless
148  of the value of `ordering'. In the case of RETURN_IN_ORDER, only
149  `--' can cause `getopt' to return -1 with `optind' != ARGC. */
150 
151 static enum
152 {
155 
156 /* Value of POSIXLY_CORRECT environment variable. */
157 static char *posixly_correct;
158 ␌
159 #include <cstring>
160 using std::strlen;
161 using std::strcmp;
162 using std::strncmp;
163 using std::strchr;
164 
165 #include <cstdlib>
166 using std::getenv;
167 
168 ␌
169 /* Handle permutation of arguments. */
170 
171 /* Describe the part of ARGV that contains non-options that have
172  been skipped. `first_nonopt' is the index in ARGV of the first of them;
173  `last_nonopt' is the index after the last of them. */
174 
175 static int first_nonopt;
176 static int last_nonopt;
177 
178 /* Exchange two adjacent subsequences of ARGV.
179  One subsequence is elements [first_nonopt,last_nonopt)
180  which contains all the non-options that have been skipped so far.
181  The other is elements [last_nonopt,optind), which contains all
182  the options processed since those non-options were skipped.
183 
184  `first_nonopt' and `last_nonopt' are relocated so that they describe
185  the new indices of the non-options in ARGV after they are moved. */
186 
187 static void
188 exchange (char **argv)
189 {
190  int bottom = first_nonopt;
191  int middle = last_nonopt;
192  int top = optind;
193  char *tem;
194 
195  /* Exchange the shorter segment with the far end of the longer segment.
196  That puts the shorter segment into the right place.
197  It leaves the longer segment in the right place overall,
198  but it consists of two parts that need to be swapped next. */
199 
200  while (top > middle && middle > bottom)
201  {
202  if (top - middle > middle - bottom)
203  {
204  /* Bottom segment is the short one. */
205  int len = middle - bottom;
206  int i;
207 
208  /* Swap it with the top part of the top segment. */
209  for (i = 0; i < len; i++)
210  {
211  tem = argv[bottom + i];
212  argv[bottom + i] = argv[top - (middle - bottom) + i];
213  argv[top - (middle - bottom) + i] = tem;
214  }
215  /* Exclude the moved bottom segment from further swapping. */
216  top -= len;
217  }
218  else
219  {
220  /* Top segment is the short one. */
221  int len = top - middle;
222  int i;
223 
224  /* Swap it with the bottom part of the bottom segment. */
225  for (i = 0; i < len; i++)
226  {
227  tem = argv[bottom + i];
228  argv[bottom + i] = argv[middle + i];
229  argv[middle + i] = tem;
230  }
231  /* Exclude the moved top segment from further swapping. */
232  bottom += len;
233  }
234  }
235 
236  /* Update records for the slots the non-options now occupy. */
237 
240 }
241 
242 /* Initialize the internal data when the first call is made. */
243 
244 static const char *
245 getopt_initialize (int argc, char *const *argv, const char *optstring)
246 {
247  /* Suppress possible unused warnings */
248  (void)argc;
249  (void)argv;
250 
251  /* Start processing options with ARGV-element 1 (since ARGV-element 0
252  is the program name); the sequence of previously skipped
253  non-option ARGV-elements is empty. */
254 
256 
257  nextchar = NULL;
258 
259  posixly_correct = getenv ("POSIXLY_CORRECT");
260 
261  /* Determine how to handle the ordering of options and nonoptions. */
262 
263  if (optstring[0] == '-')
264  {
266  ++optstring;
267  }
268  else if (optstring[0] == '+')
269  {
271  ++optstring;
272  }
273  else if (posixly_correct != NULL)
275  else
276  ordering = PERMUTE;
277 
278  return optstring;
279 }
280 ␌
281 /* Scan elements of ARGV (whose length is ARGC) for option characters
282  given in OPTSTRING.
283 
284  If an element of ARGV starts with '-', and is not exactly "-" or "--",
285  then it is an option element. The characters of this element
286  (aside from the initial '-') are option characters. If `getopt'
287  is called repeatedly, it returns successively each of the option characters
288  from each of the option elements.
289 
290  If `getopt' finds another option character, it returns that character,
291  updating `optind' and `nextchar' so that the next call to `getopt' can
292  resume the scan with the following option character or ARGV-element.
293 
294  If there are no more option characters, `getopt' returns -1.
295  Then `optind' is the index in ARGV of the first ARGV-element
296  that is not an option. (The ARGV-elements have been permuted
297  so that those that are not options now come last.)
298 
299  OPTSTRING is a string containing the legitimate option characters.
300  If an option character is seen that is not listed in OPTSTRING,
301  return '?' after printing an error message. If you set `opterr' to
302  zero, the error message is suppressed but we still return '?'.
303 
304  If a char in OPTSTRING is followed by a colon, that means it wants an arg,
305  so the following text in the same ARGV-element, or the text of the following
306  ARGV-element, is returned in `optarg'. Two colons mean an option that
307  wants an optional arg; if there is text in the current ARGV-element,
308  it is returned in `optarg', otherwise `optarg' is set to zero.
309 
310  If OPTSTRING starts with `-' or `+', it requests different methods of
311  handling the non-option ARGV-elements.
312  See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
313 
314  Long-named options begin with `--' instead of `-'.
315  Their names may be abbreviated as long as the abbreviation is unique
316  or is an exact match for some defined option. If they have an
317  argument, it follows the option name in the same ARGV-element, separated
318  from the option name by a `=', or else the in next ARGV-element.
319  When `getopt' finds a long-named option, it returns 0 if that option's
320  `flag' field is nonzero, the value of the option's `val' field
321  if the `flag' field is zero.
322 
323  The elements of ARGV aren't really const, because we permute them.
324  But we pretend they're const in the prototype to be compatible
325  with other systems.
326 
327  LONGOPTS is a vector of `struct option' terminated by an
328  element containing a name which is zero.
329 
330  LONGIND returns the index in LONGOPT of the long-named option found.
331  It is only valid when a long-named option has been found by the most
332  recent call.
333 
334  If LONG_ONLY is nonzero, '-' as well as '--' can introduce
335  long-named options. */
336 
337 int
338 gnu_getopt_internal_(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
339 {
340  int print_errors = opterr;
341  if (optstring[0] == ':')
342  print_errors = 0;
343 
344  if (argc < 1)
345  return -1;
346 
347  optarg = NULL;
348 
349  if (optind == 0 || !getopt_initialized)
350  {
351  if (optind == 0)
352  optind = 1; /* Don't scan ARGV[0], the program name. */
353  optstring = getopt_initialize (argc, argv, optstring);
354  getopt_initialized = 1;
355  }
356 
357  /* Test whether ARGV[optind] points to a non-option argument (i.e. it does
358  not have option syntax). */
359 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
360 
361  if (nextchar == NULL || *nextchar == '\0')
362  {
363  /* Advance to the next ARGV-element. */
364 
365  /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
366  moved back by the user (who may also have changed the arguments). */
367  if (last_nonopt > optind)
369  if (first_nonopt > optind)
371 
372  if (ordering == PERMUTE)
373  {
374  /* If we have just processed some options following some non-options,
375  exchange them so that the options come first. */
376 
378  exchange (const_cast<char **>(argv));
379  else if (last_nonopt != optind)
381 
382  /* Skip any additional non-options
383  and extend the range of non-options previously skipped. */
384 
385  while (optind < argc && NONOPTION_P)
386  optind++;
388  }
389 
390  /* The special ARGV-element `--' means premature end of options.
391  Skip it like a null option,
392  then exchange with previous non-options as if it were an option,
393  then skip everything else like a non-option. */
394 
395  if (optind != argc && !strcmp (argv[optind], "--"))
396  {
397  optind++;
398 
400  exchange (const_cast<char **>(argv));
401  else if (first_nonopt == last_nonopt)
403  last_nonopt = argc;
404 
405  optind = argc;
406  }
407 
408  /* If we have done all the ARGV-elements, stop the scan
409  and back over any non-options that we skipped and permuted. */
410 
411  if (optind == argc)
412  {
413  /* Set the next-arg-index to point at the non-options
414  that we previously skipped, so the caller will digest them. */
415  if (first_nonopt != last_nonopt)
417  return -1;
418  }
419 
420  /* If we have come to a non-option and did not permute it,
421  either stop the scan or describe it to the caller and pass it by. */
422 
423  if (NONOPTION_P)
424  {
425  if (ordering == REQUIRE_ORDER)
426  return -1;
427  optarg = argv[optind++];
428  return 1;
429  }
430 
431  /* We have found another option-ARGV-element.
432  Skip the initial punctuation. */
433 
434  nextchar = (argv[optind] + 1
435  + (longopts != NULL && argv[optind][1] == '-'));
436  }
437 
438  /* Decode the current option-ARGV-element. */
439 
440  /* Check whether the ARGV-element is a long option.
441 
442  If long_only and the ARGV-element has the form "-f", where f is
443  a valid short option, don't consider it an abbreviated form of
444  a long option that starts with f. Otherwise there would be no
445  way to give the -f short option.
446 
447  On the other hand, if there's a long option "fubar" and
448  the ARGV-element is "-fu", do consider that an abbreviation of
449  the long option, just like "--fu", and not "-f" with arg "u".
450 
451  This distinction seems to be the most useful approach. */
452 
453  if (longopts != NULL
454  && (argv[optind][1] == '-'
455  || (long_only && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))
456  {
457  char *nameend;
458  const struct option *p;
459  const struct option *pfound = NULL;
460  int exact = 0;
461  int ambig = 0;
462  int indfound = -1;
463  int option_index;
464 
465  for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
466  /* Do nothing. */ ;
467 
468  /* Test all long options for either exact match
469  or abbreviated matches. */
470  for (p = longopts, option_index = 0; p->name; p++, option_index++)
471  if (!strncmp (p->name, nextchar, nameend - nextchar))
472  {
473  if (unsigned(nameend - nextchar) == unsigned(strlen(p->name)))
474  {
475  /* Exact match found. */
476  pfound = p;
477  indfound = option_index;
478  exact = 1;
479  break;
480  }
481  else if (pfound == NULL)
482  {
483  /* First nonexact match found. */
484  pfound = p;
485  indfound = option_index;
486  }
487  else if (long_only
488  || pfound->has_arg != p->has_arg
489  || pfound->flag != p->flag
490  || pfound->val != p->val)
491  /* Second or later nonexact match found. */
492  ambig = 1;
493  }
494 
495  if (ambig && !exact)
496  {
497  if (print_errors)
498  fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
499  argv[0], argv[optind]);
500  nextchar += strlen (nextchar);
501  optind++;
502  optopt = 0;
503  return '?';
504  }
505 
506  if (pfound != NULL)
507  {
508  option_index = indfound;
509  optind++;
510  if (*nameend)
511  {
512  /* Don't test has_arg with >, because some C compilers don't
513  allow it to be used on enums. */
514  if (pfound->has_arg)
515  optarg = nameend + 1;
516  else
517  {
518  if (print_errors)
519  {
520  if (argv[optind - 1][1] == '-')
521  /* --option */
522  fprintf (stderr,
523  _("%s: option '--%s' doesn't allow an argument\n"),
524  argv[0], pfound->name);
525  else
526  /* +option or -option */
527  fprintf (stderr,
528  _("%s: option '%c%s' doesn't allow an argument\n"),
529  argv[0], argv[optind - 1][0], pfound->name);
530  }
531 
532  nextchar += strlen (nextchar);
533 
534  optopt = pfound->val;
535  return '?';
536  }
537  }
538  else if (pfound->has_arg == 1)
539  {
540  if (optind < argc)
541  optarg = argv[optind++];
542  else
543  {
544  if (print_errors)
545  fprintf (stderr,
546  _("%s: option '%s' requires an argument\n"),
547  argv[0], argv[optind - 1]);
548  nextchar += strlen (nextchar);
549  optopt = pfound->val;
550  return optstring[0] == ':' ? ':' : '?';
551  }
552  }
553  nextchar += strlen (nextchar);
554  if (longind != NULL)
555  *longind = option_index;
556  if (pfound->flag)
557  {
558  *(pfound->flag) = pfound->val;
559  return 0;
560  }
561  return pfound->val;
562  }
563 
564  /* Can't find it as a long option. If this is not getopt_long_only,
565  or the option starts with '--' or is not a valid short
566  option, then it's an error.
567  Otherwise interpret it as a short option. */
568  if (!long_only || argv[optind][1] == '-'
569  || strchr (optstring, *nextchar) == NULL)
570  {
571  if (print_errors)
572  {
573  if (argv[optind][1] == '-')
574  /* --option */
575  fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
576  argv[0], nextchar);
577  else
578  /* +option or -option */
579  fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
580  argv[0], argv[optind][0], nextchar);
581  }
582  nextchar = const_cast<char *>("");
583  optind++;
584  optopt = 0;
585  return '?';
586  }
587  }
588 
589  /* Look at and handle the next short option-character. */
590 
591  {
592  char c = *nextchar++;
593  const char *temp = strchr (optstring, c);
594 
595  /* Increment `optind' when we start to process its last character. */
596  if (*nextchar == '\0')
597  ++optind;
598 
599  if (temp == NULL || c == ':')
600  {
601  if (print_errors)
602  {
603  if (posixly_correct)
604  /* 1003.2 specifies the format of this message. */
605  fprintf (stderr, _("%s: illegal option -- %c\n"),
606  argv[0], c);
607  else
608  fprintf (stderr, _("%s: invalid option -- %c\n"),
609  argv[0], c);
610  }
611  optopt = c;
612  return '?';
613  }
614  /* Convenience. Treat POSIX -W foo same as long option --foo */
615  if (temp[0] == 'W' && temp[1] == ';')
616  {
617  char *nameend;
618  const struct option *p;
619  const struct option *pfound = NULL;
620  int exact = 0;
621  int ambig = 0;
622  int indfound = 0;
623  int option_index;
624 
625  /* This is an option that requires an argument. */
626  if (*nextchar != '\0')
627  {
628  optarg = nextchar;
629  /* If we end this ARGV-element by taking the rest as an arg,
630  we must advance to the next element now. */
631  optind++;
632  }
633  else if (optind == argc)
634  {
635  if (print_errors)
636  {
637  /* 1003.2 specifies the format of this message. */
638  fprintf (stderr, _("%s: option requires an argument -- %c\n"),
639  argv[0], c);
640  }
641  optopt = c;
642  if (optstring[0] == ':')
643  c = ':';
644  else
645  c = '?';
646  return c;
647  }
648  else
649  /* We already incremented `optind' once;
650  increment it again when taking next ARGV-elt as argument. */
651  optarg = argv[optind++];
652 
653  /* optarg is now the argument, see if it's in the
654  table of longopts. */
655 
656  for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
657  /* Do nothing. */ ;
658 
659  /* Test all long options for either exact match
660  or abbreviated matches. */
661  for (p = longopts, option_index = 0; p->name; p++, option_index++)
662  if (!strncmp (p->name, nextchar, nameend - nextchar))
663  {
664  if (unsigned(nameend - nextchar) == unsigned(strlen(p->name)))
665  {
666  /* Exact match found. */
667  pfound = p;
668  indfound = option_index;
669  exact = 1;
670  break;
671  }
672  else if (pfound == NULL)
673  {
674  /* First nonexact match found. */
675  pfound = p;
676  indfound = option_index;
677  }
678  else
679  /* Second or later nonexact match found. */
680  ambig = 1;
681  }
682  if (ambig && !exact)
683  {
684  if (print_errors)
685  fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
686  argv[0], argv[optind]);
687  nextchar += strlen (nextchar);
688  optind++;
689  return '?';
690  }
691  if (pfound != NULL)
692  {
693  option_index = indfound;
694  if (*nameend)
695  {
696  /* Don't test has_arg with >, because some C compilers don't
697  allow it to be used on enums. */
698  if (pfound->has_arg)
699  optarg = nameend + 1;
700  else
701  {
702  if (print_errors)
703  fprintf (stderr, _("\
704 %s: option '-W %s' doesn't allow an argument\n"),
705  argv[0], pfound->name);
706 
707  nextchar += strlen (nextchar);
708  return '?';
709  }
710  }
711  else if (pfound->has_arg == 1)
712  {
713  if (optind < argc)
714  optarg = argv[optind++];
715  else
716  {
717  if (print_errors)
718  fprintf (stderr,
719  _("%s: option '%s' requires an argument\n"),
720  argv[0], argv[optind - 1]);
721  nextchar += strlen (nextchar);
722  return optstring[0] == ':' ? ':' : '?';
723  }
724  }
725  nextchar += strlen (nextchar);
726  if (longind != NULL)
727  *longind = option_index;
728  if (pfound->flag)
729  {
730  *(pfound->flag) = pfound->val;
731  return 0;
732  }
733  return pfound->val;
734  }
735  nextchar = NULL;
736  return 'W'; /* Let the application handle it. */
737  }
738  if (temp[1] == ':')
739  {
740  if (temp[2] == ':')
741  {
742  /* This is an option that accepts an argument optionally. */
743  if (*nextchar != '\0')
744  {
745  optarg = nextchar;
746  optind++;
747  }
748  else
749  optarg = NULL;
750  nextchar = NULL;
751  }
752  else
753  {
754  /* This is an option that requires an argument. */
755  if (*nextchar != '\0')
756  {
757  optarg = nextchar;
758  /* If we end this ARGV-element by taking the rest as an arg,
759  we must advance to the next element now. */
760  optind++;
761  }
762  else if (optind == argc)
763  {
764  if (print_errors)
765  {
766  /* 1003.2 specifies the format of this message. */
767  fprintf (stderr,
768  _("%s: option requires an argument -- %c\n"),
769  argv[0], c);
770  }
771  optopt = c;
772  if (optstring[0] == ':')
773  c = ':';
774  else
775  c = '?';
776  }
777  else
778  /* We already incremented `optind' once;
779  increment it again when taking next ARGV-elt as argument. */
780  optarg = argv[optind++];
781  nextchar = NULL;
782  }
783  }
784  return c;
785  }
786 }
787 
788 #endif /* Not ELIDE_CODE. */
PositionList * p
static int getopt_initialized
Definition: getopt.cc:111
@ REQUIRE_ORDER
Definition: getopt.cc:153
@ RETURN_IN_ORDER
Definition: getopt.cc:153
@ PERMUTE
Definition: getopt.cc:153
static void exchange(char **argv)
Definition: getopt.cc:188
int optopt
Definition: getopt.cc:104
static char * nextchar
Definition: getopt.cc:120
static int last_nonopt
Definition: getopt.cc:176
#define NONOPTION_P
static int first_nonopt
Definition: getopt.cc:175
#define _(msgid)
Definition: getopt.cc:53
static const char * getopt_initialize(int argc, char *const *argv, const char *optstring)
Definition: getopt.cc:245
static enum @10 ordering
static char * posixly_correct
Definition: getopt.cc:157
int optind
Definition: getopt.cc:93
char * optarg
Definition: getopt.cc:78
int opterr
Definition: getopt.cc:98
int gnu_getopt_internal_(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
Definition: getopt.cc:338
Wrappers to allow GNU getopt to be used cleanly from C++ code.
int val
Definition: gnu_getopt.h:75
int has_arg
Definition: gnu_getopt.h:73
int * flag
Definition: gnu_getopt.h:74
const char * name
Definition: gnu_getopt.h:72