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