Mercurial > hg > octave-kai > gnulib-hg
comparison lib/getopt_int.h @ 4970:595e9138157c
Sync getopt and argp from libc CVS.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 09 Mar 2004 19:42:23 +0000 |
parents | |
children | 1c7efeb240c3 |
comparison
equal
deleted
inserted
replaced
4969:0db24850c598 | 4970:595e9138157c |
---|---|
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 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program 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 | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License along | |
17 with this program; if not, write to the Free Software Foundation, | |
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
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); | |
27 | |
28 | |
29 /* Reentrant versions which can handle parsing multiple argument | |
30 vectors at the same time. */ | |
31 | |
32 /* Data type for reentrant functions. */ | |
33 struct _getopt_data | |
34 { | |
35 /* These have exactly the same meaning as the corresponding global | |
36 variables, except that they are used for the reentrant | |
37 versions of getopt. */ | |
38 int optind; | |
39 int opterr; | |
40 int optopt; | |
41 char *optarg; | |
42 | |
43 /* Internal members. */ | |
44 | |
45 /* True if the internal members have been initialized. */ | |
46 int __initialized; | |
47 | |
48 /* The next char to be scanned in the option-element | |
49 in which the last option character we returned was found. | |
50 This allows us to pick up the scan where we left off. | |
51 | |
52 If this is zero, or a null string, it means resume the scan | |
53 by advancing to the next ARGV-element. */ | |
54 char *__nextchar; | |
55 | |
56 /* Describe how to deal with options that follow non-option ARGV-elements. | |
57 | |
58 If the caller did not specify anything, | |
59 the default is REQUIRE_ORDER if the environment variable | |
60 POSIXLY_CORRECT is defined, PERMUTE otherwise. | |
61 | |
62 REQUIRE_ORDER means don't recognize them as options; | |
63 stop option processing when the first non-option is seen. | |
64 This is what Unix does. | |
65 This mode of operation is selected by either setting the environment | |
66 variable POSIXLY_CORRECT, or using `+' as the first character | |
67 of the list of option characters. | |
68 | |
69 PERMUTE is the default. We permute the contents of ARGV as we | |
70 scan, so that eventually all the non-options are at the end. | |
71 This allows options to be given in any order, even with programs | |
72 that were not written to expect this. | |
73 | |
74 RETURN_IN_ORDER is an option available to programs that were | |
75 written to expect options and other ARGV-elements in any order | |
76 and that care about the ordering of the two. We describe each | |
77 non-option ARGV-element as if it were the argument of an option | |
78 with character code 1. Using `-' as the first character of the | |
79 list of option characters selects this mode of operation. | |
80 | |
81 The special argument `--' forces an end of option-scanning regardless | |
82 of the value of `ordering'. In the case of RETURN_IN_ORDER, only | |
83 `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | |
84 | |
85 enum | |
86 { | |
87 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | |
88 } __ordering; | |
89 | |
90 /* If the POSIXLY_CORRECT environment variable is set. */ | |
91 int __posixly_correct; | |
92 | |
93 | |
94 /* Handle permutation of arguments. */ | |
95 | |
96 /* Describe the part of ARGV that contains non-options that have | |
97 been skipped. `first_nonopt' is the index in ARGV of the first | |
98 of them; `last_nonopt' is the index after the last of them. */ | |
99 | |
100 int __first_nonopt; | |
101 int __last_nonopt; | |
102 | |
103 #if defined _LIBC && defined USE_NONOPTION_FLAGS | |
104 int __nonoption_flags_max_len; | |
105 int __nonoption_flags_len; | |
106 # endif | |
107 }; | |
108 | |
109 /* The initializer is necessary to set OPTIND and OPTERR to their | |
110 default values and to clear the initialization flag. */ | |
111 #define _GETOPT_DATA_INITIALIZER { 1, 1 } | |
112 | |
113 extern int _getopt_internal_r (int ___argc, char *const *___argv, | |
114 const char *__shortopts, | |
115 const struct option *__longopts, int *__longind, | |
116 int __long_only, struct _getopt_data *__data); | |
117 | |
118 extern int _getopt_long_r (int ___argc, char *const *___argv, | |
119 const char *__shortopts, | |
120 const struct option *__longopts, int *__longind, | |
121 struct _getopt_data *__data); | |
122 | |
123 extern int _getopt_long_only_r (int ___argc, char *const *___argv, | |
124 const char *__shortopts, | |
125 const struct option *__longopts, | |
126 int *__longind, | |
127 struct _getopt_data *__data); | |
128 | |
129 #endif /* getopt_int.h */ |