Blame h/getopt.h

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