1 | /* |
---|
2 | * Replacement implementation of getopt. |
---|
3 | * |
---|
4 | * This is a replacement implementation for getopt based on the my_getopt |
---|
5 | * distribution by Benjamin Sittler. Only the getopt interface is included, |
---|
6 | * since remctl doesn't use GNU long options, and the code has been rearranged |
---|
7 | * and reworked somewhat to fit with my coding style. |
---|
8 | * |
---|
9 | * Copyright 1997, 2000, 2001, 2002 Benjamin Sittler |
---|
10 | * Copyright 2008 Russ Allbery <rra@stanford.edu> |
---|
11 | * |
---|
12 | * Permission is hereby granted, free of charge, to any person obtaining a |
---|
13 | * copy of this software and associated documentation files (the "Software"), |
---|
14 | * to deal in the Software without restriction, including without limitation |
---|
15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
16 | * and/or sell copies of the Software, and to permit persons to whom the |
---|
17 | * Software is furnished to do so, subject to the following conditions: |
---|
18 | * |
---|
19 | * The above copyright notice and this permission notice shall be included in |
---|
20 | * all copies or substantial portions of the Software. |
---|
21 | * |
---|
22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
25 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
28 | * DEALINGS IN THE SOFTWARE. |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef PORTABLE_GETOPT_H |
---|
32 | #define PORTABLE_GETOPT_H 1 |
---|
33 | |
---|
34 | #include <config.h> |
---|
35 | #include <portable/macros.h> |
---|
36 | |
---|
37 | /* Skip this entire file if we already have a getopt. */ |
---|
38 | #if !HAVE_GETOPT |
---|
39 | |
---|
40 | BEGIN_DECLS |
---|
41 | |
---|
42 | /* The primary interface. Call repeatedly to return each option. */ |
---|
43 | int getopt(int argc, char *argv[], const char *opts); |
---|
44 | |
---|
45 | /* |
---|
46 | * The current element in the argv array or, if getopt returns -1, the index |
---|
47 | * of the first non-option argument. |
---|
48 | */ |
---|
49 | extern int optind; |
---|
50 | |
---|
51 | /* Set to zero to suppress error messages to stderr for unknown options. */ |
---|
52 | extern int opterr; |
---|
53 | |
---|
54 | /* Holds the option character seen for unrecognized options. */ |
---|
55 | extern int optopt; |
---|
56 | |
---|
57 | /* The argument to an option. */ |
---|
58 | extern char *optarg; |
---|
59 | |
---|
60 | END_DECLS |
---|
61 | |
---|
62 | #endif /* !HAVE_GETOPT */ |
---|
63 | #endif /* !PORTABLE_GETOPT_H */ |
---|