home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / graphics-0.17 / getopt / getopt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-04  |  3.1 KB  |  99 lines

  1. /* declarations for getopt
  2.    Copyright (C) 1989 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 1, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #ifdef __STDC__
  19. #define CONST const
  20. #else
  21. #define CONST
  22. #endif
  23.  
  24. /* For communication from `getopt' to the caller.
  25.    When `getopt' finds an option that takes an argument,
  26.    the argument value is returned here.
  27.    Also, when `ordering' is RETURN_IN_ORDER,
  28.    each non-option ARGV-element is returned here.  */
  29.  
  30. extern char *optarg;
  31.  
  32. /* Index in ARGV of the next element to be scanned.
  33.    This is used for communication to and from the caller
  34.    and for communication between successive calls to `getopt'.
  35.  
  36.    On entry to `getopt', zero means this is the first call; initialize.
  37.  
  38.    When `getopt' returns EOF, this is the index of the first of the
  39.    non-option elements that the caller should itself scan.
  40.  
  41.    Otherwise, `optind' communicates from one call to the next
  42.    how much of ARGV has been scanned so far.  */
  43.  
  44. extern int optind;
  45.  
  46. /* Callers store zero here to inhibit the error message `getopt' prints
  47.    for unrecognized options.  */
  48.  
  49. extern int opterr;
  50.  
  51. /* Describe the long-named options requested by the application.
  52.    _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
  53.    element containing a name which is zero.
  54.    The field `has_arg' is:
  55.    0 if the option does not take an argument,
  56.    1 if the option requires an argument,
  57.    2 if the option takes an optional argument.
  58.    If the field `flag' is nonzero, it points to a variable that is set to
  59.    the value given in the field `val' when the option is found, but
  60.    left unchanged if the option is not found.  */
  61.  
  62. struct option
  63. {
  64.   char *name;
  65.   int has_arg;
  66.   int *flag;
  67.   int val;
  68. };
  69.  
  70. extern struct option *_getopt_long_options;
  71.  
  72. /* If nonzero, tell getopt that '-' means a long option.
  73.    Set by getopt_long_only.  */
  74. extern int _getopt_long_only;
  75.  
  76. #if 0
  77. /* Name of long-named option actually found.
  78.    Only changed when a long-named option is found.
  79.    Set to zero when returning a non-option arg in `optarg'.  */
  80.  
  81. extern char *_getopt_option_name;
  82. #endif
  83.  
  84. /* The index in GETOPT_LONG_OPTIONS of the long-named option found.
  85.    Only valid when a long-named option has been found by the most
  86.    recent call to `getopt'.  */
  87.  
  88. extern int option_index;
  89.  
  90. #ifdef __STDC__
  91. int getopt (int, char **, const char *);
  92. int getopt_long (int, char **, const char *, const struct option *, int *);
  93. int getopt_long_only (int, char **, const char *, const struct option *, int *);
  94. #else
  95. int getopt ();
  96. int getopt_long ();
  97. int getopt_long_only ();
  98. #endif
  99.