Blame gnulib/lib/getopt-ext.h

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