| 1 | /* Internal declarations for getopt.
|
|---|
| 2 | Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
|---|
| 3 | This file is part of the GNU C Library and is also part of gnulib.
|
|---|
| 4 | Patches to this file should be submitted to both projects.
|
|---|
| 5 |
|
|---|
| 6 | The GNU C Library is free software; you can redistribute it and/or
|
|---|
| 7 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 8 | License as published by the Free Software Foundation; either
|
|---|
| 9 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | The GNU C Library is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | Lesser General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 17 | License along with the GNU C Library; if not, see
|
|---|
| 18 | <https://www.gnu.org/licenses/>. */
|
|---|
| 19 |
|
|---|
| 20 | #ifndef _GETOPT_INT_H
|
|---|
| 21 | #define _GETOPT_INT_H 1
|
|---|
| 22 |
|
|---|
| 23 | #include <getopt.h>
|
|---|
| 24 |
|
|---|
| 25 | extern int _getopt_internal (int ___argc, char **___argv,
|
|---|
| 26 | const char *__shortopts,
|
|---|
| 27 | const struct option *__longopts, int *__longind,
|
|---|
| 28 | int __long_only, int __posixly_correct);
|
|---|
| 29 |
|
|---|
| 30 | |
|---|
| 31 |
|
|---|
| 32 | /* Reentrant versions which can handle parsing multiple argument
|
|---|
| 33 | vectors at the same time. */
|
|---|
| 34 |
|
|---|
| 35 | /* Describe how to deal with options that follow non-option ARGV-elements.
|
|---|
| 36 |
|
|---|
| 37 | REQUIRE_ORDER means don't recognize them as options; stop option
|
|---|
| 38 | processing when the first non-option is seen. This is what POSIX
|
|---|
| 39 | specifies should happen.
|
|---|
| 40 |
|
|---|
| 41 | PERMUTE means permute the contents of ARGV as we scan, so that
|
|---|
| 42 | eventually all the non-options are at the end. This allows options
|
|---|
| 43 | to be given in any order, even with programs that were not written
|
|---|
| 44 | to expect this.
|
|---|
| 45 |
|
|---|
| 46 | RETURN_IN_ORDER is an option available to programs that were
|
|---|
| 47 | written to expect options and other ARGV-elements in any order
|
|---|
| 48 | and that care about the ordering of the two. We describe each
|
|---|
| 49 | non-option ARGV-element as if it were the argument of an option
|
|---|
| 50 | with character code 1.
|
|---|
| 51 |
|
|---|
| 52 | The special argument '--' forces an end of option-scanning regardless
|
|---|
| 53 | of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
|
|---|
| 54 | '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
|
|---|
| 55 |
|
|---|
| 56 | enum __ord
|
|---|
| 57 | {
|
|---|
| 58 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | /* Data type for reentrant functions. */
|
|---|
| 62 | struct _getopt_data
|
|---|
| 63 | {
|
|---|
| 64 | /* These have exactly the same meaning as the corresponding global
|
|---|
| 65 | variables, except that they are used for the reentrant
|
|---|
| 66 | versions of getopt. */
|
|---|
| 67 | int optind;
|
|---|
| 68 | int opterr;
|
|---|
| 69 | int optopt;
|
|---|
| 70 | char *optarg;
|
|---|
| 71 |
|
|---|
| 72 | /* Internal members. */
|
|---|
| 73 |
|
|---|
| 74 | /* True if the internal members have been initialized. */
|
|---|
| 75 | int __initialized;
|
|---|
| 76 |
|
|---|
| 77 | /* The next char to be scanned in the option-element
|
|---|
| 78 | in which the last option character we returned was found.
|
|---|
| 79 | This allows us to pick up the scan where we left off.
|
|---|
| 80 |
|
|---|
| 81 | If this is zero, or a null string, it means resume the scan
|
|---|
| 82 | by advancing to the next ARGV-element. */
|
|---|
| 83 | char *__nextchar;
|
|---|
| 84 |
|
|---|
| 85 | /* See __ord above. */
|
|---|
| 86 | enum __ord __ordering;
|
|---|
| 87 |
|
|---|
| 88 | /* Handle permutation of arguments. */
|
|---|
| 89 |
|
|---|
| 90 | /* Describe the part of ARGV that contains non-options that have
|
|---|
| 91 | been skipped. 'first_nonopt' is the index in ARGV of the first
|
|---|
| 92 | of them; 'last_nonopt' is the index after the last of them. */
|
|---|
| 93 |
|
|---|
| 94 | int __first_nonopt;
|
|---|
| 95 | int __last_nonopt;
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | /* The initializer is necessary to set OPTIND and OPTERR to their
|
|---|
| 99 | default values and to clear the initialization flag. */
|
|---|
| 100 | #define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
|---|
| 101 |
|
|---|
| 102 | extern int _getopt_internal_r (int ___argc, char **___argv,
|
|---|
| 103 | const char *__shortopts,
|
|---|
| 104 | const struct option *__longopts, int *__longind,
|
|---|
| 105 | int __long_only, struct _getopt_data *__data,
|
|---|
| 106 | int __posixly_correct);
|
|---|
| 107 |
|
|---|
| 108 | extern int _getopt_long_r (int ___argc, char **___argv,
|
|---|
| 109 | const char *__shortopts,
|
|---|
| 110 | const struct option *__longopts, int *__longind,
|
|---|
| 111 | struct _getopt_data *__data);
|
|---|
| 112 |
|
|---|
| 113 | extern int _getopt_long_only_r (int ___argc, char **___argv,
|
|---|
| 114 | const char *__shortopts,
|
|---|
| 115 | const struct option *__longopts,
|
|---|
| 116 | int *__longind,
|
|---|
| 117 | struct _getopt_data *__data);
|
|---|
| 118 |
|
|---|
| 119 | #endif /* getopt_int.h */
|
|---|