home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Snippets / getopt / getopt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-03  |  697 b   |  20 lines  |  [TEXT/R*ch]

  1. extern char *optarg;
  2. extern int optind, opterr;
  3.  
  4. extern int getopt(int argc, char *argv[], char *optstring);
  5. /* optstring are available letters for command line options.
  6.    if the letter is followed by a colon (:), the next string
  7.     will be put into "optarg" instead of interpreted.
  8. eg.
  9. ./booga -a -b -c fooga -d -- this won't be parsed
  10.  
  11. if a, b, c, and d are the possible command-line options,
  12. optstring would be "abc:d".  the -- seperates what is to be
  13. parsed from what isn't.  optarg returns the char of the
  14. string interpreted, or -1 if there are no more, or '?'
  15. if there is an unknown option.  Use repeated calls to
  16. getopt until either -1 or ? are returned to parse the entire
  17. arg list.
  18.  
  19. */
  20.