home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rcs567s.zip / diff16 / getopt.h < prev    next >
C/C++ Source or Header  |  1994-06-25  |  4KB  |  105 lines

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