getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.
* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h. Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.
2017-03-25 15:24:24 +00:00
|
|
|
/* Declarations for getopt (basic, portable features only).
|
|
|
|
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
2017-04-05 15:04:35 +00:00
|
|
|
This file is part of the GNU C Library and is also part of gnulib.
|
|
|
|
Patches to this file should be submitted to both projects.
|
getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.
* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h. Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.
2017-03-25 15:24:24 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef _GETOPT_CORE_H
|
|
|
|
#define _GETOPT_CORE_H 1
|
|
|
|
|
|
|
|
/* This header should not be used directly; include getopt.h or
|
|
|
|
unistd.h instead. Unlike most bits headers, it does not have
|
|
|
|
a protective #error, because the guard macro for getopt.h in
|
|
|
|
gnulib is not fixed. */
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
/* For communication from 'getopt' to the caller.
|
|
|
|
When 'getopt' finds an option that takes an argument,
|
|
|
|
the argument value is returned here.
|
|
|
|
Also, when 'ordering' is RETURN_IN_ORDER,
|
|
|
|
each non-option ARGV-element is returned here. */
|
|
|
|
|
|
|
|
extern char *optarg;
|
|
|
|
|
|
|
|
/* Index in ARGV of the next element to be scanned.
|
|
|
|
This is used for communication to and from the caller
|
|
|
|
and for communication between successive calls to 'getopt'.
|
|
|
|
|
|
|
|
On entry to 'getopt', zero means this is the first call; initialize.
|
|
|
|
|
|
|
|
When 'getopt' returns -1, this is the index of the first of the
|
|
|
|
non-option elements that the caller should itself scan.
|
|
|
|
|
|
|
|
Otherwise, 'optind' communicates from one call to the next
|
|
|
|
how much of ARGV has been scanned so far. */
|
|
|
|
|
|
|
|
extern int optind;
|
|
|
|
|
|
|
|
/* Callers store zero here to inhibit the error message 'getopt' prints
|
|
|
|
for unrecognized options. */
|
|
|
|
|
|
|
|
extern int opterr;
|
|
|
|
|
|
|
|
/* Set to an option character which was unrecognized. */
|
|
|
|
|
|
|
|
extern int optopt;
|
|
|
|
|
|
|
|
/* Get definitions and prototypes for functions to process the
|
|
|
|
arguments in ARGV (ARGC of them, minus the program name) for
|
|
|
|
options given in OPTS.
|
|
|
|
|
|
|
|
Return the option character from OPTS just read. Return -1 when
|
|
|
|
there are no more options. For unrecognized options, or options
|
|
|
|
missing arguments, 'optopt' is set to the option letter, and '?' is
|
|
|
|
returned.
|
|
|
|
|
|
|
|
The OPTS string is a list of characters which are recognized option
|
|
|
|
letters, optionally followed by colons, specifying that that letter
|
|
|
|
takes an argument, to be placed in 'optarg'.
|
|
|
|
|
|
|
|
If a letter in OPTS is followed by two colons, its argument is
|
|
|
|
optional. This behavior is specific to the GNU 'getopt'.
|
|
|
|
|
|
|
|
The argument '--' causes premature termination of argument
|
|
|
|
scanning, explicitly telling 'getopt' that there are no more
|
|
|
|
options.
|
|
|
|
|
|
|
|
If OPTS begins with '-', then non-option arguments are treated as
|
|
|
|
arguments to the option '\1'. This behavior is specific to the GNU
|
|
|
|
'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
|
|
|
|
the environment, then do not permute arguments.
|
|
|
|
|
|
|
|
For standards compliance, the 'argv' argument has the type
|
|
|
|
char *const *, but this is inaccurate; if argument permutation is
|
|
|
|
enabled, the argv array (not the strings it points to) must be
|
|
|
|
writable. */
|
|
|
|
|
|
|
|
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
|
|
|
__THROW __nonnull ((2, 3));
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* getopt_core.h */
|