Blame tools/getopt_win.h

Packit 664db3
/* Declarations for getopt.
Packit 664db3
   Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
Packit 664db3
   This file is part of the GNU C Library.
Packit 664db3

Packit 664db3
   The GNU C Library is free software; you can redistribute it and/or
Packit 664db3
   modify it under the terms of the GNU Library General Public License as
Packit 664db3
   published by the Free Software Foundation; either version 2 of the
Packit 664db3
   License, or (at your option) any later version.
Packit 664db3

Packit 664db3
   The GNU C Library is distributed in the hope that it will be useful,
Packit 664db3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 664db3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 664db3
   Library General Public License for more details.
Packit 664db3

Packit 664db3
   You should have received a copy of the GNU Library General Public
Packit 664db3
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
Packit 664db3
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit 664db3
   Boston, MA 02111-1307, USA.  */
Packit 664db3

Packit 664db3
#ifndef _GETOPT_H
Packit 664db3

Packit 664db3
#ifndef __need_getopt
Packit 664db3
# define _GETOPT_H 1
Packit 664db3
#endif
Packit 664db3

Packit 664db3
#ifdef	__cplusplus
Packit 664db3
extern "C" {
Packit 664db3
#endif
Packit 664db3

Packit 664db3
/* For communication from `getopt' to the caller.
Packit 664db3
   When `getopt' finds an option that takes an argument,
Packit 664db3
   the argument value is returned here.
Packit 664db3
   Also, when `ordering' is RETURN_IN_ORDER,
Packit 664db3
   each non-option ARGV-element is returned here.  */
Packit 664db3

Packit 664db3
extern char *optarg;
Packit 664db3

Packit 664db3
/* Index in ARGV of the next element to be scanned.
Packit 664db3
   This is used for communication to and from the caller
Packit 664db3
   and for communication between successive calls to `getopt'.
Packit 664db3

Packit 664db3
   On entry to `getopt', zero means this is the first call; initialize.
Packit 664db3

Packit 664db3
   When `getopt' returns -1, this is the index of the first of the
Packit 664db3
   non-option elements that the caller should itself scan.
Packit 664db3

Packit 664db3
   Otherwise, `optind' communicates from one call to the next
Packit 664db3
   how much of ARGV has been scanned so far.  */
Packit 664db3

Packit 664db3
extern int optind;
Packit 664db3

Packit 664db3
/* Callers store zero here to inhibit the error message `getopt' prints
Packit 664db3
   for unrecognized options.  */
Packit 664db3

Packit 664db3
extern int opterr;
Packit 664db3

Packit 664db3
/* Set to an option character which was unrecognized.  */
Packit 664db3

Packit 664db3
extern int optopt;
Packit 664db3

Packit 664db3
#ifndef __need_getopt
Packit 664db3
/* Describe the long-named options requested by the application.
Packit 664db3
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
Packit 664db3
   of `struct option' terminated by an element containing a name which is
Packit 664db3
   zero.
Packit 664db3

Packit 664db3
   The field `has_arg' is:
Packit 664db3
   no_argument		(or 0) if the option does not take an argument,
Packit 664db3
   required_argument	(or 1) if the option requires an argument,
Packit 664db3
   optional_argument 	(or 2) if the option takes an optional argument.
Packit 664db3

Packit 664db3
   If the field `flag' is not NULL, it points to a variable that is set
Packit 664db3
   to the value given in the field `val' when the option is found, but
Packit 664db3
   left unchanged if the option is not found.
Packit 664db3

Packit 664db3
   To have a long-named option do something other than set an `int' to
Packit 664db3
   a compiled-in constant, such as set a value from `optarg', set the
Packit 664db3
   option's `flag' field to zero and its `val' field to a nonzero
Packit 664db3
   value (the equivalent single-letter option character, if there is
Packit 664db3
   one).  For long options that have a zero `flag' field, `getopt'
Packit 664db3
   returns the contents of the `val' field.  */
Packit 664db3

Packit 664db3
struct option
Packit 664db3
{
Packit 664db3
# if defined __STDC__ && __STDC__
Packit 664db3
  const char *name;
Packit 664db3
# else
Packit 664db3
  char *name;
Packit 664db3
# endif
Packit 664db3
  /* has_arg can't be an enum because some compilers complain about
Packit 664db3
     type mismatches in all the code that assumes it is an int.  */
Packit 664db3
  int has_arg;
Packit 664db3
  int *flag;
Packit 664db3
  int val;
Packit 664db3
};
Packit 664db3

Packit 664db3
/* Names for the values of the `has_arg' field of `struct option'.  */
Packit 664db3

Packit 664db3
# define no_argument		0
Packit 664db3
# define required_argument	1
Packit 664db3
# define optional_argument	2
Packit 664db3
#endif	/* need getopt */
Packit 664db3

Packit 664db3

Packit 664db3
/* Get definitions and prototypes for functions to process the
Packit 664db3
   arguments in ARGV (ARGC of them, minus the program name) for
Packit 664db3
   options given in OPTS.
Packit 664db3

Packit 664db3
   Return the option character from OPTS just read.  Return -1 when
Packit 664db3
   there are no more options.  For unrecognized options, or options
Packit 664db3
   missing arguments, `optopt' is set to the option letter, and '?' is
Packit 664db3
   returned.
Packit 664db3

Packit 664db3
   The OPTS string is a list of characters which are recognized option
Packit 664db3
   letters, optionally followed by colons, specifying that that letter
Packit 664db3
   takes an argument, to be placed in `optarg'.
Packit 664db3

Packit 664db3
   If a letter in OPTS is followed by two colons, its argument is
Packit 664db3
   optional.  This behavior is specific to the GNU `getopt'.
Packit 664db3

Packit 664db3
   The argument `--' causes premature termination of argument
Packit 664db3
   scanning, explicitly telling `getopt' that there are no more
Packit 664db3
   options.
Packit 664db3

Packit 664db3
   If OPTS begins with `--', then non-option arguments are treated as
Packit 664db3
   arguments to the option '\0'.  This behavior is specific to the GNU
Packit 664db3
   `getopt'.  */
Packit 664db3

Packit 664db3
#if defined __STDC__ && __STDC__
Packit 664db3
# ifdef __GNU_LIBRARY__
Packit 664db3
/* Many other libraries have conflicting prototypes for getopt, with
Packit 664db3
   differences in the consts, in stdlib.h.  To avoid compilation
Packit 664db3
   errors, only prototype getopt for the GNU C library.  */
Packit 664db3
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
Packit 664db3
# else /* not __GNU_LIBRARY__ */
Packit 664db3
extern int getopt ();
Packit 664db3
# endif /* __GNU_LIBRARY__ */
Packit 664db3

Packit 664db3
# ifndef __need_getopt
Packit 664db3
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
Packit 664db3
		        const struct option *__longopts, int *__longind);
Packit 664db3
extern int getopt_long_only (int __argc, char *const *__argv,
Packit 664db3
			     const char *__shortopts,
Packit 664db3
		             const struct option *__longopts, int *__longind);
Packit 664db3

Packit 664db3
/* Internal only.  Users should not call this directly.  */
Packit 664db3
extern int _getopt_internal (int __argc, char *const *__argv,
Packit 664db3
			     const char *__shortopts,
Packit 664db3
		             const struct option *__longopts, int *__longind,
Packit 664db3
			     int __long_only);
Packit 664db3
# endif
Packit 664db3
#else /* not __STDC__ */
Packit 664db3
extern int getopt ();
Packit 664db3
# ifndef __need_getopt
Packit 664db3
extern int getopt_long ();
Packit 664db3
extern int getopt_long_only ();
Packit 664db3

Packit 664db3
extern int _getopt_internal ();
Packit 664db3
# endif
Packit 664db3
#endif /* __STDC__ */
Packit 664db3

Packit 664db3
#ifdef	__cplusplus
Packit 664db3
}
Packit 664db3
#endif
Packit 664db3

Packit 664db3
/* Make sure we later can get all the definitions and declarations.  */
Packit 664db3
#undef __need_getopt
Packit 664db3

Packit 664db3
#endif /* getopt.h */