fix dangling pointer issue. If the node being processed is replaced,
[xorcyst.git] / my_getopt.h
blob34fcfe7071c1e6dea8cb6f64d1445bff4ddb6a55
1 /*
2 * my_getopt.h - interface to my re-implementation of getopt.
3 * Copyright 1997, 2000, 2001, 2002, Benjamin Sittler
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 #ifndef MY_GETOPT_H_INCLUDED
27 #define MY_GETOPT_H_INCLUDED
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /* UNIX-style short-argument parser */
34 extern int my_getopt(int argc, char * argv[], const char *opts);
36 extern int my_optind, my_opterr, my_optopt;
37 extern char *my_optarg;
39 struct option {
40 const char *name;
41 int has_arg;
42 int *flag;
43 int val;
46 /* human-readable values for has_arg */
47 #undef no_argument
48 #define no_argument 0
49 #undef required_argument
50 #define required_argument 1
51 #undef optional_argument
52 #define optional_argument 2
54 /* GNU-style long-argument parsers */
55 extern int my_getopt_long(int argc, char * argv[], const char *shortopts,
56 const struct option *longopts, int *longind);
58 extern int my_getopt_long_only(int argc, char * argv[], const char *shortopts,
59 const struct option *longopts, int *longind);
61 extern int _my_getopt_internal(int argc, char * argv[], const char *shortopts,
62 const struct option *longopts, int *longind,
63 int long_only);
65 #ifdef __cplusplus
67 #endif
69 #endif /* MY_GETOPT_H_INCLUDED */