Blame include/getopt.h

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