Debian Codegraph @

mingw-w64-headers/crt/getopt.h

raw
1 #ifndef __GETOPT_H__
2 /**
3 * DISCLAIMER
4 * This file has no copyright assigned and is placed in the Public Domain.
5 * This file is part of the mingw-w64 runtime package.
6 *
7 * The mingw-w64 runtime package and its code is distributed in the hope that it
8 * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
9 * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
10 * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 */
12
13 #define __GETOPT_H__
14
15 /* All the headers include this file. */
16 #include <crtdefs.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 extern int optind; /* index of first non-option in argv */
23 extern int optopt; /* single option character, as parsed */
24 extern int opterr; /* flag to enable built-in diagnostics... */
25 /* (user may set to zero, to suppress) */
26
27 extern char *optarg; /* pointer to argument of current option */
28
29 extern int getopt(int nargc, char * const *nargv, const char *options);
30
31 #ifdef __cplusplus
32 }
33 #endif
34 /*
35 * POSIX requires the `getopt' API to be specified in `unistd.h';
36 * thus, `unistd.h' includes this header. However, we do not want
37 * to expose the `getopt_long' or `getopt_long_only' APIs, when
38 * included in this manner. Thus, close the standard __GETOPT_H__
39 * declarations block, and open an additional __GETOPT_LONG_H__
40 * specific block, only when *not* __UNISTD_H_SOURCED__, in which
41 * to declare the extended API.
42 */
43 #endif /* !defined(__GETOPT_H__) */
44
45 #if !defined(__GETOPT_BSD_H__) && defined(_BSD_SOURCE)
46 #define __GETOPT_BSD_H__
47 /*
48 * BSD adds the non-standard `optreset' feature, for reinitialisation
49 * of `getopt' parsing. We support this feature, for applications which
50 * proclaim their BSD heritage, before including this header; however,
51 * to maintain portability, developers are advised to avoid it.
52 */
53 # define optreset __mingw_optreset
54 extern int optreset;
55 #endif /* !defined(__GETOPT_BSD_H__) && defined(_BSD_SOURCE) */
56
57 #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
58 #define __GETOPT_LONG_H__
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 struct option /* specification for a long form option... */
65 {
66 const char *name; /* option name, without leading hyphens */
67 int has_arg; /* does it take an argument? */
68 int *flag; /* where to save its status, or NULL */
69 int val; /* its associated status value */
70 };
71
72 enum /* permitted values for its `has_arg' field... */
73 {
74 no_argument = 0, /* option never takes an argument */
75 required_argument, /* option always requires an argument */
76 optional_argument /* option may take an argument */
77 };
78
79 extern int getopt_long(int nargc, char * const *nargv, const char *options,
80 const struct option *long_options, int *idx);
81 extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
82 const struct option *long_options, int *idx);
83 /*
84 * Previous MinGW implementation had...
85 */
86 #ifndef HAVE_DECL_GETOPT
87 /*
88 * ...for the long form API only; keep this for compatibility.
89 */
90 # define HAVE_DECL_GETOPT 1
91 #endif
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */