xref: /aosp_15_r20/external/libdav1d/include/compat/getopt.h (revision c09093415860a1c2373dacd84c4fde00c507cdfd)
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 #ifdef _WIN32
17 #include <crtdefs.h>
18 #endif
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 extern int optind;		/* index of first non-option in argv      */
25 extern int optopt;		/* single option character, as parsed     */
26 extern int opterr;		/* flag to enable built-in diagnostics... */
27 				/* (user may set to zero, to suppress)    */
28 
29 extern char *optarg;		/* pointer to argument of current option  */
30 
31 extern int getopt(int nargc, char * const *nargv, const char *options);
32 
33 #ifdef _BSD_SOURCE
34 /*
35  * BSD adds the non-standard `optreset' feature, for reinitialisation
36  * of `getopt' parsing.  We support this feature, for applications which
37  * proclaim their BSD heritage, before including this header; however,
38  * to maintain portability, developers are advised to avoid it.
39  */
40 # define optreset  __mingw_optreset
41 extern int optreset;
42 #endif
43 #ifdef __cplusplus
44 }
45 #endif
46 /*
47  * POSIX requires the `getopt' API to be specified in `unistd.h';
48  * thus, `unistd.h' includes this header.  However, we do not want
49  * to expose the `getopt_long' or `getopt_long_only' APIs, when
50  * included in this manner.  Thus, close the standard __GETOPT_H__
51  * declarations block, and open an additional __GETOPT_LONG_H__
52  * specific block, only when *not* __UNISTD_H_SOURCED__, in which
53  * to declare the extended API.
54  */
55 #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
56 #define __GETOPT_LONG_H__
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 struct option		/* specification for a long form option...	*/
63 {
64   const char *name;		/* option name, without leading hyphens */
65   int         has_arg;		/* does it take an argument?		*/
66   int        *flag;		/* where to save its status, or NULL	*/
67   int         val;		/* its associated status value		*/
68 };
69 
70 enum    		/* permitted values for its `has_arg' field...	*/
71 {
72   no_argument = 0,      	/* option never takes an argument	*/
73   required_argument,		/* option always requires an argument	*/
74   optional_argument		/* option may take an argument		*/
75 };
76 
77 extern int getopt_long(int nargc, char * const *nargv, const char *options,
78     const struct option *long_options, int *idx);
79 extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
80     const struct option *long_options, int *idx);
81 /*
82  * Previous MinGW implementation had...
83  */
84 #ifndef HAVE_DECL_GETOPT
85 /*
86  * ...for the long form API only; keep this for compatibility.
87  */
88 # define HAVE_DECL_GETOPT	1
89 #endif
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
96 
97 #endif /* !defined(__GETOPT_H__) */
98