Blame posix/bits/getopt_ext.h

Packit 6c4009
/* Declarations for getopt (GNU extensions).
Packit 6c4009
   Copyright (C) 1989-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library and is also part of gnulib.
Packit 6c4009
   Patches to this file should be submitted to both projects.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _GETOPT_EXT_H
Packit 6c4009
#define _GETOPT_EXT_H 1
Packit 6c4009
Packit 6c4009
/* This header should not be used directly; include getopt.h instead.
Packit 6c4009
   Unlike most bits headers, it does not have a protective #error,
Packit 6c4009
   because the guard macro for getopt.h in gnulib is not fixed.  */
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Describe the long-named options requested by the application.
Packit 6c4009
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
Packit 6c4009
   of 'struct option' terminated by an element containing a name which is
Packit 6c4009
   zero.
Packit 6c4009
Packit 6c4009
   The field 'has_arg' is:
Packit 6c4009
   no_argument		(or 0) if the option does not take an argument,
Packit 6c4009
   required_argument	(or 1) if the option requires an argument,
Packit 6c4009
   optional_argument 	(or 2) if the option takes an optional argument.
Packit 6c4009
Packit 6c4009
   If the field 'flag' is not NULL, it points to a variable that is set
Packit 6c4009
   to the value given in the field 'val' when the option is found, but
Packit 6c4009
   left unchanged if the option is not found.
Packit 6c4009
Packit 6c4009
   To have a long-named option do something other than set an 'int' to
Packit 6c4009
   a compiled-in constant, such as set a value from 'optarg', set the
Packit 6c4009
   option's 'flag' field to zero and its 'val' field to a nonzero
Packit 6c4009
   value (the equivalent single-letter option character, if there is
Packit 6c4009
   one).  For long options that have a zero 'flag' field, 'getopt'
Packit 6c4009
   returns the contents of the 'val' field.  */
Packit 6c4009
Packit 6c4009
struct option
Packit 6c4009
{
Packit 6c4009
  const char *name;
Packit 6c4009
  /* has_arg can't be an enum because some compilers complain about
Packit 6c4009
     type mismatches in all the code that assumes it is an int.  */
Packit 6c4009
  int has_arg;
Packit 6c4009
  int *flag;
Packit 6c4009
  int val;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Names for the values of the 'has_arg' field of 'struct option'.  */
Packit 6c4009
Packit 6c4009
#define no_argument		0
Packit 6c4009
#define required_argument	1
Packit 6c4009
#define optional_argument	2
Packit 6c4009
Packit 6c4009
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
Packit 6c4009
			const char *__shortopts,
Packit 6c4009
		        const struct option *__longopts, int *__longind)
Packit 6c4009
       __THROW __nonnull ((2, 3));
Packit 6c4009
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
Packit 6c4009
			     const char *__shortopts,
Packit 6c4009
		             const struct option *__longopts, int *__longind)
Packit 6c4009
       __THROW __nonnull ((2, 3));
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* getopt_ext.h */