Blame lib/getopt-ext.h

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