Blame src/getopt.h

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