Blame src/getopt.h

Packit cb6d3d
/* Declarations for getopt.
Packit cb6d3d
   Copyright (C) 1989-2014 Free Software Foundation, Inc.
Packit cb6d3d
   This file is part of the GNU C Library.
Packit cb6d3d
Packit cb6d3d
   The GNU C Library is free software; you can redistribute it and/or
Packit cb6d3d
   modify it under the terms of the GNU Lesser General Public
Packit cb6d3d
   License as published by the Free Software Foundation; either
Packit cb6d3d
   version 2.1 of the License, or (at your option) any later version.
Packit cb6d3d
Packit cb6d3d
   The GNU C Library is distributed in the hope that it will be useful,
Packit cb6d3d
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit cb6d3d
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit cb6d3d
   Lesser General Public License for more details.
Packit cb6d3d
Packit cb6d3d
   You should have received a copy of the GNU Lesser General Public
Packit cb6d3d
   License along with the GNU C Library; if not, see
Packit cb6d3d
   <http://www.gnu.org/licenses/>.  */
Packit cb6d3d
Packit cb6d3d
#ifndef _GETOPT_H
Packit cb6d3d
Packit cb6d3d
#ifndef __need_getopt
Packit cb6d3d
# define _GETOPT_H 1
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
/* If __GNU_LIBRARY__ is not already defined, either we are being used
Packit cb6d3d
   standalone, or this is the first header included in the source file.
Packit cb6d3d
   If we are being used with glibc, we need to include <features.h>, but
Packit cb6d3d
   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
Packit cb6d3d
   not defined, include <ctype.h>, which will pull in <features.h> for us
Packit cb6d3d
   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
Packit cb6d3d
   doesn't flood the namespace with stuff the way some other headers do.)  */
Packit cb6d3d
#if !defined __GNU_LIBRARY__
Packit cb6d3d
# include <ctype.h>
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
#ifndef __THROW
Packit cb6d3d
# ifndef __GNUC_PREREQ
Packit cb6d3d
#  define __GNUC_PREREQ(maj, min) (0)
Packit cb6d3d
# endif
Packit cb6d3d
# if defined __cplusplus && __GNUC_PREREQ (2,8)
Packit cb6d3d
#  define __THROW	throw ()
Packit cb6d3d
# else
Packit cb6d3d
#  define __THROW
Packit cb6d3d
# endif
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
#ifdef	__cplusplus
Packit cb6d3d
extern "C" {
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
/* For communication from `getopt' to the caller.
Packit cb6d3d
   When `getopt' finds an option that takes an argument,
Packit cb6d3d
   the argument value is returned here.
Packit cb6d3d
   Also, when `ordering' is RETURN_IN_ORDER,
Packit cb6d3d
   each non-option ARGV-element is returned here.  */
Packit cb6d3d
Packit cb6d3d
extern char *optarg;
Packit cb6d3d
Packit cb6d3d
/* Index in ARGV of the next element to be scanned.
Packit cb6d3d
   This is used for communication to and from the caller
Packit cb6d3d
   and for communication between successive calls to `getopt'.
Packit cb6d3d
Packit cb6d3d
   On entry to `getopt', zero means this is the first call; initialize.
Packit cb6d3d
Packit cb6d3d
   When `getopt' returns -1, this is the index of the first of the
Packit cb6d3d
   non-option elements that the caller should itself scan.
Packit cb6d3d
Packit cb6d3d
   Otherwise, `optind' communicates from one call to the next
Packit cb6d3d
   how much of ARGV has been scanned so far.  */
Packit cb6d3d
Packit cb6d3d
extern int optind;
Packit cb6d3d
Packit cb6d3d
/* Callers store zero here to inhibit the error message `getopt' prints
Packit cb6d3d
   for unrecognized options.  */
Packit cb6d3d
Packit cb6d3d
extern int opterr;
Packit cb6d3d
Packit cb6d3d
/* Set to an option character which was unrecognized.  */
Packit cb6d3d
Packit cb6d3d
extern int optopt;
Packit cb6d3d
Packit cb6d3d
#ifndef __need_getopt
Packit cb6d3d
/* Describe the long-named options requested by the application.
Packit cb6d3d
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
Packit cb6d3d
   of `struct option' terminated by an element containing a name which is
Packit cb6d3d
   zero.
Packit cb6d3d
Packit cb6d3d
   The field `has_arg' is:
Packit cb6d3d
   no_argument		(or 0) if the option does not take an argument,
Packit cb6d3d
   required_argument	(or 1) if the option requires an argument,
Packit cb6d3d
   optional_argument 	(or 2) if the option takes an optional argument.
Packit cb6d3d
Packit cb6d3d
   If the field `flag' is not NULL, it points to a variable that is set
Packit cb6d3d
   to the value given in the field `val' when the option is found, but
Packit cb6d3d
   left unchanged if the option is not found.
Packit cb6d3d
Packit cb6d3d
   To have a long-named option do something other than set an `int' to
Packit cb6d3d
   a compiled-in constant, such as set a value from `optarg', set the
Packit cb6d3d
   option's `flag' field to zero and its `val' field to a nonzero
Packit cb6d3d
   value (the equivalent single-letter option character, if there is
Packit cb6d3d
   one).  For long options that have a zero `flag' field, `getopt'
Packit cb6d3d
   returns the contents of the `val' field.  */
Packit cb6d3d
Packit cb6d3d
struct option
Packit cb6d3d
{
Packit cb6d3d
  const char *name;
Packit cb6d3d
  /* has_arg can't be an enum because some compilers complain about
Packit cb6d3d
     type mismatches in all the code that assumes it is an int.  */
Packit cb6d3d
  int has_arg;
Packit cb6d3d
  int *flag;
Packit cb6d3d
  int val;
Packit cb6d3d
};
Packit cb6d3d
Packit cb6d3d
/* Names for the values of the `has_arg' field of `struct option'.  */
Packit cb6d3d
Packit cb6d3d
# define no_argument		0
Packit cb6d3d
# define required_argument	1
Packit cb6d3d
# define optional_argument	2
Packit cb6d3d
#endif	/* need getopt */
Packit cb6d3d
Packit cb6d3d
Packit cb6d3d
/* Get definitions and prototypes for functions to process the
Packit cb6d3d
   arguments in ARGV (ARGC of them, minus the program name) for
Packit cb6d3d
   options given in OPTS.
Packit cb6d3d
Packit cb6d3d
   Return the option character from OPTS just read.  Return -1 when
Packit cb6d3d
   there are no more options.  For unrecognized options, or options
Packit cb6d3d
   missing arguments, `optopt' is set to the option letter, and '?' is
Packit cb6d3d
   returned.
Packit cb6d3d
Packit cb6d3d
   The OPTS string is a list of characters which are recognized option
Packit cb6d3d
   letters, optionally followed by colons, specifying that that letter
Packit cb6d3d
   takes an argument, to be placed in `optarg'.
Packit cb6d3d
Packit cb6d3d
   If a letter in OPTS is followed by two colons, its argument is
Packit cb6d3d
   optional.  This behavior is specific to the GNU `getopt'.
Packit cb6d3d
Packit cb6d3d
   The argument `--' causes premature termination of argument
Packit cb6d3d
   scanning, explicitly telling `getopt' that there are no more
Packit cb6d3d
   options.
Packit cb6d3d
Packit cb6d3d
   If OPTS begins with `--', then non-option arguments are treated as
Packit cb6d3d
   arguments to the option '\0'.  This behavior is specific to the GNU
Packit cb6d3d
   `getopt'.  */
Packit cb6d3d
Packit cb6d3d
#ifdef __GNU_LIBRARY__
Packit cb6d3d
/* Many other libraries have conflicting prototypes for getopt, with
Packit cb6d3d
   differences in the consts, in stdlib.h.  To avoid compilation
Packit cb6d3d
   errors, only prototype getopt for the GNU C library.  */
Packit cb6d3d
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
Packit cb6d3d
       __THROW;
Packit cb6d3d
Packit cb6d3d
# if defined __need_getopt && defined __USE_POSIX2 \
Packit cb6d3d
  && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
Packit cb6d3d
/* The GNU getopt has more functionality than the standard version.  The
Packit cb6d3d
   additional functionality can be disable at runtime.  This redirection
Packit cb6d3d
   helps to also do this at runtime.  */
Packit cb6d3d
#  ifdef __REDIRECT
Packit cb6d3d
  extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
Packit cb6d3d
				      const char *__shortopts),
Packit cb6d3d
			     __posix_getopt);
Packit cb6d3d
#  else
Packit cb6d3d
extern int __posix_getopt (int ___argc, char *const *___argv,
Packit cb6d3d
			   const char *__shortopts) __THROW;
Packit cb6d3d
#   define getopt __posix_getopt
Packit cb6d3d
#  endif
Packit cb6d3d
# endif
Packit cb6d3d
#else /* not __GNU_LIBRARY__ */
Packit cb6d3d
extern int getopt ();
Packit cb6d3d
#endif /* __GNU_LIBRARY__ */
Packit cb6d3d
Packit cb6d3d
#ifndef __need_getopt
Packit cb6d3d
extern int getopt_long (int ___argc, char *const *___argv,
Packit cb6d3d
			const char *__shortopts,
Packit cb6d3d
		        const struct option *__longopts, int *__longind)
Packit cb6d3d
       __THROW;
Packit cb6d3d
extern int getopt_long_only (int ___argc, char *const *___argv,
Packit cb6d3d
			     const char *__shortopts,
Packit cb6d3d
		             const struct option *__longopts, int *__longind)
Packit cb6d3d
       __THROW;
Packit cb6d3d
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
#ifdef	__cplusplus
Packit cb6d3d
}
Packit cb6d3d
#endif
Packit cb6d3d
Packit cb6d3d
/* Make sure we later can get all the definitions and declarations.  */
Packit cb6d3d
#undef __need_getopt
Packit cb6d3d
Packit cb6d3d
#endif /* getopt.h */