getopt_vars.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stdio.h>
  2. /*
  3. * Getopt vars shared between getopt and gnu_getopt
  4. */
  5. /* For communication from `getopt' to the caller.
  6. When `getopt' finds an option that takes an argument,
  7. the argument value is returned here.
  8. Also, when `ordering' is RETURN_IN_ORDER,
  9. each non-option ARGV-element is returned here. */
  10. char *optarg = NULL;
  11. /* Index in ARGV of the next element to be scanned.
  12. This is used for communication to and from the caller
  13. and for communication between successive calls to `getopt'.
  14. On entry to `getopt', zero means this is the first call; initialize.
  15. When `getopt' returns EOF, this is the index of the first of the
  16. non-option elements that the caller should itself scan.
  17. Otherwise, `optind' communicates from one call to the next
  18. how much of ARGV has been scanned so far. */
  19. /* XXX 1003.2 says this must be 1 before any call. */
  20. int optind = 0;
  21. /* Callers store zero here to inhibit the error message
  22. for unrecognized options. */
  23. int opterr = 1;
  24. /* Set to an option character which was unrecognized.
  25. This must be initialized on some systems to avoid linking in the
  26. system's own getopt implementation. */
  27. int optopt = '?';