1151497Sru/* Internal declarations for getopt.
2151497Sru   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
3151497Sru   Free Software Foundation, Inc.
4151497Sru   This file is part of the GNU C Library.
5151497Sru
6151497Sru   This program is free software; you can redistribute it and/or modify
7151497Sru   it under the terms of the GNU General Public License as published by
8151497Sru   the Free Software Foundation; either version 2, or (at your option)
9151497Sru   any later version.
10151497Sru
11151497Sru   This program is distributed in the hope that it will be useful,
12151497Sru   but WITHOUT ANY WARRANTY; without even the implied warranty of
13151497Sru   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14151497Sru   GNU General Public License for more details.
15151497Sru
16151497Sru   You should have received a copy of the GNU General Public License along
17151497Sru   with this program; if not, write to the Free Software Foundation,
18151497Sru   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19151497Sru
20151497Sru#ifndef _GETOPT_INT_H
21151497Sru#define _GETOPT_INT_H	1
22151497Sru
23151497Sruextern int _getopt_internal (int ___argc, char **___argv,
24151497Sru			     const char *__shortopts,
25151497Sru		             const struct option *__longopts, int *__longind,
26151497Sru			     int __long_only, int __posixly_correct);
27151497Sru
28151497Sru
29151497Sru/* Reentrant versions which can handle parsing multiple argument
30151497Sru   vectors at the same time.  */
31151497Sru
32151497Sru/* Data type for reentrant functions.  */
33151497Srustruct _getopt_data
34151497Sru{
35151497Sru  /* These have exactly the same meaning as the corresponding global
36151497Sru     variables, except that they are used for the reentrant
37151497Sru     versions of getopt.  */
38151497Sru  int optind;
39151497Sru  int opterr;
40151497Sru  int optopt;
41151497Sru  char *optarg;
42151497Sru
43151497Sru  /* Internal members.  */
44151497Sru
45151497Sru  /* True if the internal members have been initialized.  */
46151497Sru  int __initialized;
47151497Sru
48151497Sru  /* The next char to be scanned in the option-element
49151497Sru     in which the last option character we returned was found.
50151497Sru     This allows us to pick up the scan where we left off.
51151497Sru
52151497Sru     If this is zero, or a null string, it means resume the scan
53151497Sru     by advancing to the next ARGV-element.  */
54151497Sru  char *__nextchar;
55151497Sru
56151497Sru  /* Describe how to deal with options that follow non-option ARGV-elements.
57151497Sru
58151497Sru     If the caller did not specify anything,
59151497Sru     the default is REQUIRE_ORDER if the environment variable
60151497Sru     POSIXLY_CORRECT is defined, PERMUTE otherwise.
61151497Sru
62151497Sru     REQUIRE_ORDER means don't recognize them as options;
63151497Sru     stop option processing when the first non-option is seen.
64151497Sru     This is what Unix does.
65151497Sru     This mode of operation is selected by either setting the environment
66151497Sru     variable POSIXLY_CORRECT, or using `+' as the first character
67151497Sru     of the list of option characters, or by calling getopt.
68151497Sru
69151497Sru     PERMUTE is the default.  We permute the contents of ARGV as we
70151497Sru     scan, so that eventually all the non-options are at the end.
71151497Sru     This allows options to be given in any order, even with programs
72151497Sru     that were not written to expect this.
73151497Sru
74151497Sru     RETURN_IN_ORDER is an option available to programs that were
75151497Sru     written to expect options and other ARGV-elements in any order
76151497Sru     and that care about the ordering of the two.  We describe each
77151497Sru     non-option ARGV-element as if it were the argument of an option
78151497Sru     with character code 1.  Using `-' as the first character of the
79151497Sru     list of option characters selects this mode of operation.
80151497Sru
81151497Sru     The special argument `--' forces an end of option-scanning regardless
82151497Sru     of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
83151497Sru     `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
84151497Sru
85151497Sru  enum
86151497Sru    {
87151497Sru      REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
88151497Sru    } __ordering;
89151497Sru
90151497Sru  /* If the POSIXLY_CORRECT environment variable is set
91151497Sru     or getopt was called.  */
92151497Sru  int __posixly_correct;
93151497Sru
94151497Sru
95151497Sru  /* Handle permutation of arguments.  */
96151497Sru
97151497Sru  /* Describe the part of ARGV that contains non-options that have
98151497Sru     been skipped.  `first_nonopt' is the index in ARGV of the first
99151497Sru     of them; `last_nonopt' is the index after the last of them.  */
100151497Sru
101151497Sru  int __first_nonopt;
102151497Sru  int __last_nonopt;
103151497Sru
104151497Sru#if defined _LIBC && defined USE_NONOPTION_FLAGS
105151497Sru  int __nonoption_flags_max_len;
106151497Sru  int __nonoption_flags_len;
107151497Sru# endif
108151497Sru};
109151497Sru
110151497Sru/* The initializer is necessary to set OPTIND and OPTERR to their
111151497Sru   default values and to clear the initialization flag.  */
112151497Sru#define _GETOPT_DATA_INITIALIZER	{ 1, 1 }
113151497Sru
114151497Sruextern int _getopt_internal_r (int ___argc, char **___argv,
115151497Sru			       const char *__shortopts,
116151497Sru			       const struct option *__longopts, int *__longind,
117151497Sru			       int __long_only, int __posixly_correct,
118151497Sru			       struct _getopt_data *__data);
119151497Sru
120151497Sruextern int _getopt_long_r (int ___argc, char **___argv,
121151497Sru			   const char *__shortopts,
122151497Sru			   const struct option *__longopts, int *__longind,
123151497Sru			   struct _getopt_data *__data);
124151497Sru
125151497Sruextern int _getopt_long_only_r (int ___argc, char **___argv,
126151497Sru				const char *__shortopts,
127151497Sru				const struct option *__longopts,
128151497Sru				int *__longind,
129151497Sru				struct _getopt_data *__data);
130151497Sru
131151497Sru#endif /* getopt_int.h */
132