Blame libs/getopt/getopt.h

Packit Service 48484a
/* Declarations for getopt.
Packit Service 48484a
   Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Packit Service 48484a
Packit Service 48484a
   This program is free software; you can redistribute it and/or modify it
Packit Service 48484a
   under the terms of the GNU General Public License as published by the
Packit Service 48484a
   Free Software Foundation; either version 2, or (at your option) any
Packit Service 48484a
   later version.
Packit Service 48484a
Packit Service 48484a
   This program is distributed in the hope that it will be useful,
Packit Service 48484a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 48484a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 48484a
   GNU General Public License for more details.
Packit Service 48484a
Packit Service 48484a
   You should have received a copy of the GNU General Public License
Packit Service 48484a
   along with this program; if not, write to the Free Software
Packit Service 48484a
   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
Packit Service 48484a
Packit Service 48484a
#ifndef _GETOPT_H
Packit Service 48484a
#define _GETOPT_H 1
Packit Service 48484a
Packit Service 48484a
#ifdef	__cplusplus
Packit Service 48484a
extern "C" {
Packit Service 48484a
#endif
Packit Service 48484a
Packit Service 48484a
/* For communication from `getopt' to the caller.
Packit Service 48484a
   When `getopt' finds an option that takes an argument,
Packit Service 48484a
   the argument value is returned here.
Packit Service 48484a
   Also, when `ordering' is RETURN_IN_ORDER,
Packit Service 48484a
   each non-option ARGV-element is returned here.  */
Packit Service 48484a
Packit Service 48484a
extern char *optarg;
Packit Service 48484a
Packit Service 48484a
/* Index in ARGV of the next element to be scanned.
Packit Service 48484a
   This is used for communication to and from the caller
Packit Service 48484a
   and for communication between successive calls to `getopt'.
Packit Service 48484a
Packit Service 48484a
   On entry to `getopt', zero means this is the first call; initialize.
Packit Service 48484a
Packit Service 48484a
   When `getopt' returns EOF, this is the index of the first of the
Packit Service 48484a
   non-option elements that the caller should itself scan.
Packit Service 48484a
Packit Service 48484a
   Otherwise, `optind' communicates from one call to the next
Packit Service 48484a
   how much of ARGV has been scanned so far.  */
Packit Service 48484a
Packit Service 48484a
extern int optind;
Packit Service 48484a
Packit Service 48484a
/* Callers store zero here to inhibit the error message `getopt' prints
Packit Service 48484a
   for unrecognized options.  */
Packit Service 48484a
Packit Service 48484a
extern int opterr;
Packit Service 48484a
Packit Service 48484a
/* Set to an option character which was unrecognized.  */
Packit Service 48484a
Packit Service 48484a
extern int optopt;
Packit Service 48484a
Packit Service 48484a
/* Describe the long-named options requested by the application.
Packit Service 48484a
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
Packit Service 48484a
   of `struct option' terminated by an element containing a name which is
Packit Service 48484a
   zero.
Packit Service 48484a
Packit Service 48484a
   The field `has_arg' is:
Packit Service 48484a
   no_argument		(or 0) if the option does not take an argument,
Packit Service 48484a
   required_argument	(or 1) if the option requires an argument,
Packit Service 48484a
   optional_argument 	(or 2) if the option takes an optional argument.
Packit Service 48484a
Packit Service 48484a
   If the field `flag' is not NULL, it points to a variable that is set
Packit Service 48484a
   to the value given in the field `val' when the option is found, but
Packit Service 48484a
   left unchanged if the option is not found.
Packit Service 48484a
Packit Service 48484a
   To have a long-named option do something other than set an `int' to
Packit Service 48484a
   a compiled-in constant, such as set a value from `optarg', set the
Packit Service 48484a
   option's `flag' field to zero and its `val' field to a nonzero
Packit Service 48484a
   value (the equivalent single-letter option character, if there is
Packit Service 48484a
   one).  For long options that have a zero `flag' field, `getopt'
Packit Service 48484a
   returns the contents of the `val' field.  */
Packit Service 48484a
Packit Service 48484a
struct option
Packit Service 48484a
{
Packit Service 48484a
#if	__STDC__ || _MSC_VER || defined(XP_OS2_VACPP)
Packit Service 48484a
  const char *name;
Packit Service 48484a
#else
Packit Service 48484a
  char *name;
Packit Service 48484a
#endif
Packit Service 48484a
  /* has_arg can't be an enum because some compilers complain about
Packit Service 48484a
     type mismatches in all the code that assumes it is an int.  */
Packit Service 48484a
  int has_arg;
Packit Service 48484a
  int *flag;
Packit Service 48484a
  int val;
Packit Service 48484a
};
Packit Service 48484a
Packit Service 48484a
/* Names for the values of the `has_arg' field of `struct option'.  */
Packit Service 48484a
Packit Service 48484a
#define	no_argument		0
Packit Service 48484a
#define required_argument	1
Packit Service 48484a
#define optional_argument	2
Packit Service 48484a
Packit Service 48484a
#if __STDC__ || _MSC_VER || defined( XP_OS2_VACPP )
Packit Service 48484a
#if defined(__GNU_LIBRARY__) || defined( XP_OS2_VACPP ) || defined(_MSC_VER)
Packit Service 48484a
/* Many other libraries have conflicting prototypes for getopt, with
Packit Service 48484a
   differences in the consts, in stdlib.h.  To avoid compilation
Packit Service 48484a
   errors, only prototype getopt for the GNU C library.  */
Packit Service 48484a
extern int getopt (int argc, char *const *argv, const char *shortopts);
Packit Service 48484a
#else /* not __GNU_LIBRARY__ */
Packit Service 48484a
extern int getopt ();
Packit Service 48484a
#endif /* not __GNU_LIBRARY__ */
Packit Service 48484a
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
Packit Service 48484a
		        const struct option *longopts, int *longind);
Packit Service 48484a
extern int getopt_long_only (int argc, char *const *argv,
Packit Service 48484a
			     const char *shortopts,
Packit Service 48484a
		             const struct option *longopts, int *longind);
Packit Service 48484a
Packit Service 48484a
/* Internal only.  Users should not call this directly.  */
Packit Service 48484a
extern int _getopt_internal (int argc, char *const *argv,
Packit Service 48484a
			     const char *shortopts,
Packit Service 48484a
		             const struct option *longopts, int *longind,
Packit Service 48484a
			     int long_only);
Packit Service 48484a
#else /* not __STDC__ */
Packit Service 48484a
extern int getopt ();
Packit Service 48484a
extern int getopt_long ();
Packit Service 48484a
extern int getopt_long_only ();
Packit Service 48484a
Packit Service 48484a
extern int _getopt_internal ();
Packit Service 48484a
#endif /* not __STDC__ */
Packit Service 48484a
Packit Service 48484a
#ifdef	__cplusplus
Packit Service 48484a
}
Packit Service 48484a
#endif
Packit Service 48484a
Packit Service 48484a
#endif /* _GETOPT_H */