Blame lib/getopt.h

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