Blame include/getopt.h

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