Debian Codegraph @

compat/getopt.h

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