OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libc / unistd / getopt_int.h
1 /* Internal declarations for getopt.
2    Copyright (C) 1989-1994,1996-1999,2001,2003,2004
3    Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
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    <http://www.gnu.org/licenses/>.  */
19
20 #ifndef _GETOPT_INT_H
21 #define _GETOPT_INT_H   1
22
23 extern int _getopt_internal (int ___argc, char *const *___argv,
24                              const char *__shortopts,
25                              const struct option *__longopts, int *__longind,
26                              int __long_only) attribute_hidden;
27
28
29 /* Reentrant versions which can handle parsing multiple argument
30    vectors at the same time.  */
31
32 /* For __ordering member */
33 enum {
34         REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
35 };
36
37 /* Data type for reentrant functions.  */
38
39 struct _getopt_data
40 {
41   /* These have exactly the same meaning as the corresponding global
42      variables, except that they are used for the reentrant
43      versions of getopt.  */
44   int optind;
45   int opterr;
46   char *optarg;
47   smalluint optopt; /* we store characters here, a byte is enough */
48
49   /* Internal members.  */
50
51   /* True if the internal members have been initialized.  */
52   smallint __initialized;
53
54   /* Describe how to deal with options that follow non-option ARGV-elements.
55
56      If the caller did not specify anything,
57      the default is REQUIRE_ORDER if the environment variable
58      POSIXLY_CORRECT is defined, PERMUTE otherwise.
59
60      REQUIRE_ORDER means don't recognize them as options;
61      stop option processing when the first non-option is seen.
62      This is what Unix does.
63      This mode of operation is selected by either setting the environment
64      variable POSIXLY_CORRECT, or using `+' as the first character
65      of the list of option characters.
66
67      PERMUTE is the default.  We permute the contents of ARGV as we
68      scan, so that eventually all the non-options are at the end.
69      This allows options to be given in any order, even with programs
70      that were not written to expect this.
71
72      RETURN_IN_ORDER is an option available to programs that were
73      written to expect options and other ARGV-elements in any order
74      and that care about the ordering of the two.  We describe each
75      non-option ARGV-element as if it were the argument of an option
76      with character code 1.  Using `-' as the first character of the
77      list of option characters selects this mode of operation.
78
79      The special argument `--' forces an end of option-scanning regardless
80      of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
81      `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
82   smallint __ordering;
83
84   /* If the POSIXLY_CORRECT environment variable is set.  */
85   smallint __posixly_correct;
86
87   /* The next char to be scanned in the option-element
88      in which the last option character we returned was found.
89      This allows us to pick up the scan where we left off.
90
91      If this is zero, or a null string, it means resume the scan
92      by advancing to the next ARGV-element.  */
93   char *__nextchar;
94
95
96   /* Handle permutation of arguments.  */
97
98   /* Describe the part of ARGV that contains non-options that have
99      been skipped.  `first_nonopt' is the index in ARGV of the first
100      of them; `last_nonopt' is the index after the last of them.  */
101
102   int __first_nonopt;
103   int __last_nonopt;
104
105 #if defined _LIBC && defined USE_NONOPTION_FLAGS
106   int __nonoption_flags_max_len;
107   int __nonoption_flags_len;
108 # endif
109 };
110
111 /* The initializer is necessary to set OPTIND and OPTERR to their
112    default values and to clear the initialization flag.  */
113 #define _GETOPT_DATA_INITIALIZER        { 1, 1 }
114
115 #if 0 /* first is static on uClibc, the others not used */
116 extern int _getopt_internal_r (int ___argc, char *const *___argv,
117                                const char *__shortopts,
118                                const struct option *__longopts, int *__longind,
119                                int __long_only, struct _getopt_data *__data);
120
121 extern int _getopt_long_r (int ___argc, char *const *___argv,
122                            const char *__shortopts,
123                            const struct option *__longopts, int *__longind,
124                            struct _getopt_data *__data);
125
126 extern int _getopt_long_only_r (int ___argc, char *const *___argv,
127                                 const char *__shortopts,
128                                 const struct option *__longopts,
129                                 int *__longind,
130                                 struct _getopt_data *__data);
131 #endif
132
133 #endif /* getopt_int.h */