Blame lib/getopt-ext.h

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