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