annotate liboctave/getopt.h @ 5018:1c65a8e44ef9 ss-2-1-59

[project @ 2004-09-22 03:33:29 by jwe]
author jwe
date Wed, 22 Sep 2004 03:33:29 +0000
parents 7d48a8fba1d4
children 4c8a2e4e0717
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
1 /* Declarations for getopt.
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
2 Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
3
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
4 This file is part of the GNU C Library. Its master source is NOT part of
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
5 the C library, however. The master source lives in /gd/gnu/lib.
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
6
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
7 The GNU C Library is free software; you can redistribute it and/or
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
8 modify it under the terms of the GNU Library General Public License as
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
9 published by the Free Software Foundation; either version 2 of the
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
10 License, or (at your option) any later version.
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
11
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
12 The GNU C Library is distributed in the hope that it will be useful,
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
15 Library General Public License for more details.
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
16
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
17 You should have received a copy of the GNU Library General Public
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
20 Boston, MA 02111-1307, USA. */
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
21
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
22 #ifndef _GETOPT_H
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
23 #define _GETOPT_H 1
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
24
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
25 #if !defined(WIN32) || (defined(_DLL) && !defined(_IMPORT)) || !defined(_DLL)
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
26 #define DllImport
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
27 #else
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
28 #define DllImport __declspec(dllimport)
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
29 #endif
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
30
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
31 #ifdef __cplusplus
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
32 extern "C" {
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
33 #endif
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
34
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
35 /* For communication from `getopt' to the caller.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
36 When `getopt' finds an option that takes an argument,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
37 the argument value is returned here.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
38 Also, when `ordering' is RETURN_IN_ORDER,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
39 each non-option ARGV-element is returned here. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
40
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
41 extern DllImport char *optarg;
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
42
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
43 /* Index in ARGV of the next element to be scanned.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
44 This is used for communication to and from the caller
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
45 and for communication between successive calls to `getopt'.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
46
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
47 On entry to `getopt', zero means this is the first call; initialize.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
48
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
49 When `getopt' returns -1, this is the index of the first of the
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
50 non-option elements that the caller should itself scan.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
51
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
52 Otherwise, `optind' communicates from one call to the next
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
53 how much of ARGV has been scanned so far. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
54
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
55 extern DllImport int optind;
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
56
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
57 /* Callers store zero here to inhibit the error message `getopt' prints
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
58 for unrecognized options. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
59
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
60 extern DllImport int opterr;
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
61
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
62 /* Set to an option character which was unrecognized. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
63
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
64 extern DllImport int optopt;
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
65
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
66 /* Describe the long-named options requested by the application.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
67 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
68 of `struct option' terminated by an element containing a name which is
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
69 zero.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
70
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
71 The field `has_arg' is:
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
72 no_argument (or 0) if the option does not take an argument,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
73 required_argument (or 1) if the option requires an argument,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
74 optional_argument (or 2) if the option takes an optional argument.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
75
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
76 If the field `flag' is not NULL, it points to a variable that is set
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
77 to the value given in the field `val' when the option is found, but
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
78 left unchanged if the option is not found.
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
79
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
80 To have a long-named option do something other than set an `int' to
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
81 a compiled-in constant, such as set a value from `optarg', set the
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
82 option's `flag' field to zero and its `val' field to a nonzero
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
83 value (the equivalent single-letter option character, if there is
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
84 one). For long options that have a zero `flag' field, `getopt'
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
85 returns the contents of the `val' field. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
86
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
87 struct option
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
88 {
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
89 #if defined (__STDC__) && __STDC__
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
90 const char *name;
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
91 #else
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
92 char *name;
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
93 #endif
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
94 /* has_arg can't be an enum because some compilers complain about
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
95 type mismatches in all the code that assumes it is an int. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
96 int has_arg;
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
97 int *flag;
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
98 int val;
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
99 };
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
100
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
101 /* Names for the values of the `has_arg' field of `struct option'. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
102
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
103 #define no_argument 0
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
104 #define required_argument 1
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
105 #define optional_argument 2
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
106
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
107 #if defined (__STDC__) && __STDC__
4378
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
108 #ifdef __GNU_LIBRARY__
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
109 /* Many other libraries have conflicting prototypes for getopt, with
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
110 differences in the consts, in stdlib.h. To avoid compilation
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
111 errors, only prototype getopt for the GNU C library. */
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
112 extern int getopt (int argc, char *const *argv, const char *shortopts);
4378
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
113 #else /* not __GNU_LIBRARY__ */
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
114 extern int getopt ();
7d48a8fba1d4 [project @ 2003-04-19 00:03:47 by jwe]
jwe
parents: 4289
diff changeset
115 #endif /* __GNU_LIBRARY__ */
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
116 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
117 const struct option *longopts, int *longind);
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
118 extern int getopt_long_only (int argc, char *const *argv,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
119 const char *shortopts,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
120 const struct option *longopts, int *longind);
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
121
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
122 /* Internal only. Users should not call this directly. */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
123 extern int _getopt_internal (int argc, char *const *argv,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
124 const char *shortopts,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
125 const struct option *longopts, int *longind,
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
126 int long_only);
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
127 #else /* not __STDC__ */
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
128 extern int getopt ();
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
129 extern int getopt_long ();
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
130 extern int getopt_long_only ();
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
131
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
132 extern int _getopt_internal ();
4288
3788d56fea50 [project @ 2003-01-04 21:40:52 by jwe]
jwe
parents: 4093
diff changeset
133 #endif /* __STDC__ */
141
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
134
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
135 #ifdef __cplusplus
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
136 }
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
137 #endif
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
138
9d169ddba3b1 [project @ 1993-09-29 23:24:50 by jwe]
jwe
parents:
diff changeset
139 #endif /* _GETOPT_H */