Blame lib/getopt.h

Packit 15a96c
/* Declarations for getopt.
Packit 15a96c
   Copyright (C) 1989,90,91,92,93,94,96,97, 98 Free Software Foundation, Inc.
Packit 15a96c
Packit 15a96c
   This file is part of the GNU C Library.  Its master source is NOT part of
Packit 15a96c
   the C library, however.  The master source lives in /gd/gnu/lib.
Packit 15a96c
Packit 15a96c
   The GNU C Library is free software; you can redistribute it and/or
Packit 15a96c
   modify it under the terms of the GNU Library General Public License as
Packit 15a96c
   published by the Free Software Foundation; either version 2 of the
Packit 15a96c
   License, or (at your option) any later version.
Packit 15a96c
Packit 15a96c
   The GNU C Library is distributed in the hope that it will be useful,
Packit 15a96c
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 15a96c
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 15a96c
   Library General Public License for more details.
Packit 15a96c
Packit 15a96c
   You should have received a copy of the GNU Library General Public
Packit 15a96c
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
Packit 15a96c
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit 15a96c
   Boston, MA 02111-1307, USA.  */
Packit 15a96c
Packit 15a96c
#ifndef _GETOPT_H
Packit 15a96c
#define _GETOPT_H 1
Packit 15a96c
Packit 15a96c
#ifdef	__cplusplus
Packit 15a96c
extern "C" {
Packit 15a96c
#endif
Packit 15a96c
Packit 15a96c
/* For communication from `getopt' to the caller.
Packit 15a96c
   When `getopt' finds an option that takes an argument,
Packit 15a96c
   the argument value is returned here.
Packit 15a96c
   Also, when `ordering' is RETURN_IN_ORDER,
Packit 15a96c
   each non-option ARGV-element is returned here.  */
Packit 15a96c
Packit 15a96c
extern char *optarg;
Packit 15a96c
Packit 15a96c
/* Index in ARGV of the next element to be scanned.
Packit 15a96c
   This is used for communication to and from the caller
Packit 15a96c
   and for communication between successive calls to `getopt'.
Packit 15a96c
Packit 15a96c
   On entry to `getopt', zero means this is the first call; initialize.
Packit 15a96c
Packit 15a96c
   When `getopt' returns -1, this is the index of the first of the
Packit 15a96c
   non-option elements that the caller should itself scan.
Packit 15a96c
Packit 15a96c
   Otherwise, `optind' communicates from one call to the next
Packit 15a96c
   how much of ARGV has been scanned so far.  */
Packit 15a96c
Packit 15a96c
extern int optind;
Packit 15a96c
Packit 15a96c
/* Callers store zero here to inhibit the error message `getopt' prints
Packit 15a96c
   for unrecognized options.  */
Packit 15a96c
Packit 15a96c
extern int opterr;
Packit 15a96c
Packit 15a96c
/* Set to an option character which was unrecognized.  */
Packit 15a96c
Packit 15a96c
extern int optopt;
Packit 15a96c
Packit 15a96c
/* Describe the long-named options requested by the application.
Packit 15a96c
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
Packit 15a96c
   of `struct option' terminated by an element containing a name which is
Packit 15a96c
   zero.
Packit 15a96c
Packit 15a96c
   The field `has_arg' is:
Packit 15a96c
   no_argument		(or 0) if the option does not take an argument,
Packit 15a96c
   required_argument	(or 1) if the option requires an argument,
Packit 15a96c
   optional_argument 	(or 2) if the option takes an optional argument.
Packit 15a96c
Packit 15a96c
   If the field `flag' is not NULL, it points to a variable that is set
Packit 15a96c
   to the value given in the field `val' when the option is found, but
Packit 15a96c
   left unchanged if the option is not found.
Packit 15a96c
Packit 15a96c
   To have a long-named option do something other than set an `int' to
Packit 15a96c
   a compiled-in constant, such as set a value from `optarg', set the
Packit 15a96c
   option's `flag' field to zero and its `val' field to a nonzero
Packit 15a96c
   value (the equivalent single-letter option character, if there is
Packit 15a96c
   one).  For long options that have a zero `flag' field, `getopt'
Packit 15a96c
   returns the contents of the `val' field.  */
Packit 15a96c
Packit 15a96c
struct option
Packit 15a96c
{
Packit 15a96c
#if defined(__cplusplus) || (defined (__STDC__) && __STDC__)
Packit 15a96c
  const char *name;
Packit 15a96c
#else
Packit 15a96c
  char *name;
Packit 15a96c
#endif
Packit 15a96c
  /* has_arg can't be an enum because some compilers complain about
Packit 15a96c
     type mismatches in all the code that assumes it is an int.  */
Packit 15a96c
  int has_arg;
Packit 15a96c
  int *flag;
Packit 15a96c
  int val;
Packit 15a96c
};
Packit 15a96c
Packit 15a96c
/* Names for the values of the `has_arg' field of `struct option'.  */
Packit 15a96c
Packit 15a96c
#define	no_argument		0
Packit 15a96c
#define required_argument	1
Packit 15a96c
#define optional_argument	2
Packit 15a96c
Packit 15a96c
#if defined(__cplusplus) || (defined (__STDC__) && __STDC__)
Packit 15a96c
#ifdef __GNU_LIBRARY__
Packit 15a96c
/* Many other libraries have conflicting prototypes for getopt, with
Packit 15a96c
   differences in the consts, in stdlib.h.  To avoid compilation
Packit 15a96c
   errors, only prototype getopt for the GNU C library.  */
Packit 15a96c
extern int getopt (int argc, char *const *argv, const char *shortopts);
Packit 15a96c
#else /* not __GNU_LIBRARY__ */
Packit 15a96c
/*extern int getopt ();*/
Packit 15a96c
#endif /* __GNU_LIBRARY__ */
Packit 15a96c
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
Packit 15a96c
		        const struct option *longopts, int *longind);
Packit 15a96c
extern int getopt_long_only (int argc, char *const *argv,
Packit 15a96c
			     const char *shortopts,
Packit 15a96c
		             const struct option *longopts, int *longind);
Packit 15a96c
Packit 15a96c
/* Internal only.  Users should not call this directly.  */
Packit 15a96c
extern int _getopt_internal (int argc, char *const *argv,
Packit 15a96c
			     const char *shortopts,
Packit 15a96c
		             const struct option *longopts, int *longind,
Packit 15a96c
			     int long_only);
Packit 15a96c
#else /* not __STDC__ */
Packit 15a96c
extern int getopt ();
Packit 15a96c
extern int getopt_long ();
Packit 15a96c
extern int getopt_long_only ();
Packit 15a96c
Packit 15a96c
extern int _getopt_internal ();
Packit 15a96c
#endif /* __STDC__ */
Packit 15a96c
Packit 15a96c
#ifdef	__cplusplus
Packit 15a96c
}
Packit 15a96c
#endif
Packit 15a96c
Packit 15a96c
#endif /* _GETOPT_H */