Blame include/share/getopt.h

Packit Service 065837
/*
Packit Service 065837
	NOTE:
Packit Service 065837
	I cannot get the vanilla getopt code to work (i.e. compile only what
Packit Service 065837
	is needed and not duplicate symbols found in the standard library)
Packit Service 065837
	on all the platforms that FLAC supports.  In particular the gating
Packit Service 065837
	of code with the ELIDE_CODE #define is not accurate enough on systems
Packit Service 065837
	that are POSIX but not glibc.  If someone has a patch that works on
Packit Service 065837
	GNU/Linux, Darwin, AND Solaris please submit it on the project page:
Packit Service 065837
		https://sourceforge.net/p/flac/patches/
Packit Service 065837
Packit Service 065837
	In the meantime I have munged the global symbols and removed gates
Packit Service 065837
	around code, while at the same time trying to touch the original as
Packit Service 065837
	little as possible.
Packit Service 065837
*/
Packit Service 065837
/* Declarations for getopt.
Packit Service 065837
   Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
Packit Service 065837
   This file is part of the GNU C Library.
Packit Service 065837
Packit Service 065837
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 065837
   modify it under the terms of the GNU Library General Public License as
Packit Service 065837
   published by the Free Software Foundation; either version 2 of the
Packit Service 065837
   License, or (at your option) any later version.
Packit Service 065837
Packit Service 065837
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 065837
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 065837
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 065837
   Library General Public License for more details.
Packit Service 065837
Packit Service 065837
   You should have received a copy of the GNU Library General Public
Packit Service 065837
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
Packit Service 065837
   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit Service 065837
   Boston, MA 02110-1301, USA.  */
Packit Service 065837
Packit Service 065837
#ifndef SHARE__GETOPT_H
Packit Service 065837
#define SHARE__GETOPT_H
Packit Service 065837
Packit Service 065837
/*[JEC] was:#ifndef __need_getopt*/
Packit Service 065837
/*[JEC] was:# define _GETOPT_H 1*/
Packit Service 065837
/*[JEC] was:#endif*/
Packit Service 065837
Packit Service 065837
#ifdef	__cplusplus
Packit Service 065837
extern "C" {
Packit Service 065837
#endif
Packit Service 065837
Packit Service 065837
/* For communication from `share__getopt' to the caller.
Packit Service 065837
   When `share__getopt' finds an option that takes an argument,
Packit Service 065837
   the argument value is returned here.
Packit Service 065837
   Also, when `ordering' is RETURN_IN_ORDER,
Packit Service 065837
   each non-option ARGV-element is returned here.  */
Packit Service 065837
Packit Service 065837
extern char *share__optarg;
Packit Service 065837
Packit Service 065837
/* Index in ARGV of the next element to be scanned.
Packit Service 065837
   This is used for communication to and from the caller
Packit Service 065837
   and for communication between successive calls to `share__getopt'.
Packit Service 065837
Packit Service 065837
   On entry to `share__getopt', zero means this is the first call; initialize.
Packit Service 065837
Packit Service 065837
   When `share__getopt' returns -1, this is the index of the first of the
Packit Service 065837
   non-option elements that the caller should itself scan.
Packit Service 065837
Packit Service 065837
   Otherwise, `share__optind' communicates from one call to the next
Packit Service 065837
   how much of ARGV has been scanned so far.  */
Packit Service 065837
Packit Service 065837
extern int share__optind;
Packit Service 065837
Packit Service 065837
/* Callers store zero here to inhibit the error message `share__getopt' prints
Packit Service 065837
   for unrecognized options.  */
Packit Service 065837
Packit Service 065837
extern int share__opterr;
Packit Service 065837
Packit Service 065837
/* Set to an option character which was unrecognized.  */
Packit Service 065837
Packit Service 065837
extern int share__optopt;
Packit Service 065837
Packit Service 065837
/*[JEC] was:#ifndef __need_getopt */
Packit Service 065837
/* Describe the long-named options requested by the application.
Packit Service 065837
   The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
Packit Service 065837
   of `struct share__option' terminated by an element containing a name which is
Packit Service 065837
   zero.
Packit Service 065837
Packit Service 065837
   The field `has_arg' is:
Packit Service 065837
   share__no_argument		(or 0) if the option does not take an argument,
Packit Service 065837
   share__required_argument	(or 1) if the option requires an argument,
Packit Service 065837
   share__optional_argument 	(or 2) if the option takes an optional argument.
Packit Service 065837
Packit Service 065837
   If the field `flag' is not NULL, it points to a variable that is set
Packit Service 065837
   to the value given in the field `val' when the option is found, but
Packit Service 065837
   left unchanged if the option is not found.
Packit Service 065837
Packit Service 065837
   To have a long-named option do something other than set an `int' to
Packit Service 065837
   a compiled-in constant, such as set a value from `share__optarg', set the
Packit Service 065837
   option's `flag' field to zero and its `val' field to a nonzero
Packit Service 065837
   value (the equivalent single-letter option character, if there is
Packit Service 065837
   one).  For long options that have a zero `flag' field, `share__getopt'
Packit Service 065837
   returns the contents of the `val' field.  */
Packit Service 065837
Packit Service 065837
struct share__option
Packit Service 065837
{
Packit Service 065837
# if defined __STDC__ && __STDC__
Packit Service 065837
  const char *name;
Packit Service 065837
# else
Packit Service 065837
  char *name;
Packit Service 065837
# endif
Packit Service 065837
  /* has_arg can't be an enum because some compilers complain about
Packit Service 065837
     type mismatches in all the code that assumes it is an int.  */
Packit Service 065837
  int has_arg;
Packit Service 065837
  int *flag;
Packit Service 065837
  int val;
Packit Service 065837
};
Packit Service 065837
Packit Service 065837
/* Names for the values of the `has_arg' field of `struct share__option'.  */
Packit Service 065837
Packit Service 065837
# define share__no_argument		0
Packit Service 065837
# define share__required_argument	1
Packit Service 065837
# define share__optional_argument	2
Packit Service 065837
/*[JEC] was:#endif*/	/* need getopt */
Packit Service 065837
Packit Service 065837
Packit Service 065837
/* Get definitions and prototypes for functions to process the
Packit Service 065837
   arguments in ARGV (ARGC of them, minus the program name) for
Packit Service 065837
   options given in OPTS.
Packit Service 065837
Packit Service 065837
   Return the option character from OPTS just read.  Return -1 when
Packit Service 065837
   there are no more options.  For unrecognized options, or options
Packit Service 065837
   missing arguments, `share__optopt' is set to the option letter, and '?' is
Packit Service 065837
   returned.
Packit Service 065837
Packit Service 065837
   The OPTS string is a list of characters which are recognized option
Packit Service 065837
   letters, optionally followed by colons, specifying that that letter
Packit Service 065837
   takes an argument, to be placed in `share__optarg'.
Packit Service 065837
Packit Service 065837
   If a letter in OPTS is followed by two colons, its argument is
Packit Service 065837
   optional.  This behavior is specific to the GNU `share__getopt'.
Packit Service 065837
Packit Service 065837
   The argument `--' causes premature termination of argument
Packit Service 065837
   scanning, explicitly telling `share__getopt' that there are no more
Packit Service 065837
   options.
Packit Service 065837
Packit Service 065837
   If OPTS begins with `--', then non-option arguments are treated as
Packit Service 065837
   arguments to the option '\0'.  This behavior is specific to the GNU
Packit Service 065837
   `share__getopt'.  */
Packit Service 065837
Packit Service 065837
/*[JEC] was:#if defined __STDC__ && __STDC__*/
Packit Service 065837
/*[JEC] was:# ifdef __GNU_LIBRARY__*/
Packit Service 065837
/* Many other libraries have conflicting prototypes for getopt, with
Packit Service 065837
   differences in the consts, in stdlib.h.  To avoid compilation
Packit Service 065837
   errors, only prototype getopt for the GNU C library.  */
Packit Service 065837
extern int share__getopt (int argc, char *const *argv, const char *shortopts);
Packit Service 065837
/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
Packit Service 065837
/*[JEC] was:extern int getopt ();*/
Packit Service 065837
/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
Packit Service 065837
Packit Service 065837
/*[JEC] was:# ifndef __need_getopt*/
Packit Service 065837
extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
Packit Service 065837
		        const struct share__option *longopts, int *longind);
Packit Service 065837
extern int share__getopt_long_only (int argc, char *const *argv,
Packit Service 065837
			     const char *shortopts,
Packit Service 065837
		             const struct share__option *longopts, int *longind);
Packit Service 065837
Packit Service 065837
/* Internal only.  Users should not call this directly.  */
Packit Service 065837
extern int share___getopt_internal (int argc, char *const *argv,
Packit Service 065837
			     const char *shortopts,
Packit Service 065837
		             const struct share__option *longopts, int *longind,
Packit Service 065837
			     int long_only);
Packit Service 065837
/*[JEC] was:# endif*/
Packit Service 065837
/*[JEC] was:#else*/ /* not __STDC__ */
Packit Service 065837
/*[JEC] was:extern int getopt ();*/
Packit Service 065837
/*[JEC] was:# ifndef __need_getopt*/
Packit Service 065837
/*[JEC] was:extern int getopt_long ();*/
Packit Service 065837
/*[JEC] was:extern int getopt_long_only ();*/
Packit Service 065837
Packit Service 065837
/*[JEC] was:extern int _getopt_internal ();*/
Packit Service 065837
/*[JEC] was:# endif*/
Packit Service 065837
/*[JEC] was:#endif*/ /* __STDC__ */
Packit Service 065837
Packit Service 065837
#ifdef	__cplusplus
Packit Service 065837
}
Packit Service 065837
#endif
Packit Service 065837
Packit Service 065837
/* Make sure we later can get all the definitions and declarations.  */
Packit Service 065837
/*[JEC] was:#undef __need_getopt*/
Packit Service 065837
Packit Service 065837
#endif /* getopt.h */