Changeset 3213 for trunk/src/kmk/kmkbuiltin/getopt_r.h
- Timestamp:
- Mar 30, 2018, 11:03:28 PM (7 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/getopt_r.h
r3212 r3213 1 /* Declarations for getopt. 1 /* Reentrant version of getopt. 2 3 Based on ../getopt*.*: 4 5 Declarations for getopt. 2 6 Copyright (C) 1989-2016 Free Software Foundation, Inc. 3 7 … … 15 19 16 20 You should have received a copy of the GNU General Public License along with 17 this program. If not, see <http://www.gnu.org/licenses/>. */21 this program. If not, see <http://www.gnu.org/licenses/>. 18 22 19 #ifndef _GETOPT_H 20 #define _GETOPT_H 1 23 Modifications: 24 Copyright (c) 2018 knut st. osmundsen <bird-kBuild-spamx@anduin.net> 25 */ 26 27 /* Not quite safe to mix when converting code. */ 28 #ifdef _GETOPT_H 29 # define _GETOPT_H "getopt.h was included already" 30 # error "getopt.h was included already" 31 #endif 32 33 #ifndef INCLUDED_GETOPT_R_H 34 #define INCLUDED_GETOPT_R_H 1 21 35 22 36 #ifdef __cplusplus 23 37 extern "C" { 24 38 #endif 39 40 typedef struct getopt_state_r 41 { 25 42 26 43 /* For communication from `getopt' to the caller. … … 30 47 each non-option ARGV-element is returned here. */ 31 48 32 externchar *optarg;49 /*extern*/ char *optarg; 33 50 34 51 /* Index in ARGV of the next element to be scanned. … … 44 61 how much of ARGV has been scanned so far. */ 45 62 46 externint optind;63 /*extern*/ int optind; 47 64 48 65 /* Callers store zero here to inhibit the error message `getopt' prints 49 66 for unrecognized options. */ 50 67 51 externint opterr;68 /*extern*/ int opterr; 52 69 53 70 /* Set to an option character which was unrecognized. */ 54 71 55 extern int optopt; 72 /*extern*/ int optopt; 73 74 75 /* Internal state: */ 76 77 /* The next char to be scanned in the option-element 78 in which the last option character we returned was found. 79 This allows us to pick up the scan where we left off. 80 81 If this is zero, or a null string, it means resume the scan 82 by advancing to the next ARGV-element. */ 83 84 /*static*/ char *nextchar; 85 86 /* REQUIRE_ORDER, PERMUTE or RETURN_IN_ORDER, see getopt_r.c. */ 87 /*static*/ int ordering; 88 89 /* Value of POSIXLY_CORRECT environment variable. */ 90 /*static*/ char *posixly_correct; 91 92 /* Describe the part of ARGV that contains non-options that have 93 been skipped. `first_nonopt' is the index in ARGV of the first of them; 94 `last_nonopt' is the index after the last of them. */ 95 96 /*static*/ int first_nonopt; 97 /*static*/ int last_nonopt; 98 99 /* Mainly for asserting usage sanity. */ 100 /*static*/ void *__getopt_initialized; 101 102 /* New internal state (to resubmitting same parameters in each call): */ 103 /* new: the argument vector length. */ 104 int argc; 105 /* new: the argument vector. */ 106 char * const *argv; 107 /* new: the short option string (can be NULL/empty). */ 108 const char *optstring; 109 /* new: the short option string length. */ 110 size_t len_optstring; 111 /* new: the long options (can be NULL) */ 112 const struct option *long_options; 113 /* Output context for err.h. */ 114 struct KMKBUILTINCTX *pCtx; 115 } getopt_state_r; 116 117 118 #ifndef no_argument 56 119 57 120 /* Describe the long-named options requested by the application. … … 96 159 #define optional_argument 2 97 160 98 #if defined (__STDC__) && __STDC__ 99 #ifdef __GNU_LIBRARY__ 100 /* Many other libraries have conflicting prototypes for getopt, with 101 differences in the consts, in stdlib.h. To avoid compilation 102 errors, only prototype getopt for the GNU C library. */ 103 extern int getopt (int argc, char *const *argv, const char *shortopts); 104 #else /* not __GNU_LIBRARY__ */ 105 extern int getopt (); 106 #endif /* __GNU_LIBRARY__ */ 107 extern int getopt_long (int argc, char *const *argv, const char *shortopts, 108 const struct option *longopts, int *longind); 109 extern int getopt_long_only (int argc, char *const *argv, 110 const char *shortopts, 111 const struct option *longopts, int *longind); 161 #endif /* Same as ../getopt.h. Fix later? */ 162 163 extern void getopt_initialize_r (struct getopt_state_r *gos, int argc, 164 char *const *argv, const char *shortopts, 165 const struct option *longopts, 166 char **envp, struct KMKBUILTINCTX *pCtx); 167 extern int getopt_r (struct getopt_state_r *gos); 168 extern int getopt_long_r (struct getopt_state_r *gos, int *longind); 169 extern int getopt_long_only_r (struct getopt_state_r *gos, int *longind); 112 170 113 171 /* Internal only. Users should not call this directly. */ 114 extern int _getopt_internal (int argc, char *const *argv, 115 const char *shortopts, 116 const struct option *longopts, int *longind, 117 int long_only); 118 #else /* not __STDC__ */ 119 extern int getopt (); 120 extern int getopt_long (); 121 extern int getopt_long_only (); 122 123 extern int _getopt_internal (); 124 #endif /* __STDC__ */ 172 extern int _getopt_internal_r (struct getopt_state_r *gos, 173 const struct option *longopts, 174 int *longind, int long_only); 125 175 126 176 #ifdef __cplusplus … … 128 178 #endif 129 179 130 #endif /* getopt .h */180 #endif /* getopt_r.h */
Note:
See TracChangeset
for help on using the changeset viewer.