OSDN Git Service

Declare the nanosleep() function where POSIX expects it.
[mingw/mingw-org-wsl.git] / mingwrt / include / getopt.h
1 #ifndef __GETOPT_H__
2 /*
3  * getopt.h
4  *
5  * $Id$
6  *
7  * Defines constants and function prototypes required to implement
8  * the `getopt', `getopt_long' and `getopt_long_only' APIs.
9  *
10  * This file is part of the MinGW32 package set.
11  *
12  * Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
13  *
14  *
15  * THIS SOFTWARE IS NOT COPYRIGHTED
16  *
17  * This source code is offered for use in the public domain. You may
18  * use, modify or distribute it freely.
19  *
20  * This code is distributed in the hope that it will be useful but
21  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
22  * DISCLAIMED. This includes but is not limited to warranties of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24  *
25  * $Revision$
26  * $Author$
27  * $Date$
28  *
29  */
30 #define __GETOPT_H__
31
32 /* All the headers include this file. */
33 #include <_mingw.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 extern int optind;              /* index of first non-option in argv      */
40 extern int optopt;              /* single option character, as parsed     */
41 extern int opterr;              /* flag to enable built-in diagnostics... */
42                                 /* (user may set to zero, to suppress)    */
43
44 extern char *optarg;            /* pointer to argument of current option  */
45
46 extern int getopt( int, char * const [], const char * );
47
48 #ifdef _BSD_SOURCE
49 /*
50  * BSD adds the non-standard `optreset' feature, for reinitialisation
51  * of `getopt' parsing.  We support this feature, for applications which
52  * proclaim their BSD heritage, before including this header; however,
53  * to maintain portability, developers are advised to avoid it.
54  */
55 # define optreset  __mingw_optreset
56
57 extern int optreset;
58 #endif
59 #ifdef __cplusplus
60 }
61 #endif
62 /*
63  * POSIX requires the `getopt' API to be specified in `unistd.h';
64  * thus, `unistd.h' includes this header.  However, we do not want
65  * to expose the `getopt_long' or `getopt_long_only' APIs, when
66  * included in this manner.  Thus, close the standard __GETOPT_H__
67  * declarations block, and open an additional __GETOPT_LONG_H__
68  * specific block, only when *not* __UNISTD_H_SOURCED__, in which
69  * to declare the extended API.
70  */
71 #endif /* !defined(__GETOPT_H__) */
72 #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
73 #define __GETOPT_LONG_H__
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 struct option           /* specification for a long form option...      */
80 {
81   const char *name;             /* option name, without leading hyphens */
82   int         has_arg;          /* does it take an argument?            */
83   int        *flag;             /* where to save its status, or NULL    */
84   int         val;              /* its associated status value          */
85 };
86
87 enum                    /* permitted values for its `has_arg' field...  */
88 {
89   no_argument = 0,              /* option never takes an argument       */
90   required_argument,            /* option always requires an argument   */
91   optional_argument             /* option may take an argument          */
92 };
93
94 extern int getopt_long( int, char * const [], const char *, const struct option *, int * );
95 extern int getopt_long_only( int, char * const [], const char *, const struct option *, int * );
96 /*
97  * Previous MinGW implementation had...
98  */
99 #ifndef HAVE_DECL_GETOPT
100 /*
101  * ...for the long form API only; keep this for compatibility.
102  */
103 # define HAVE_DECL_GETOPT       1
104 #endif
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
111 /* $RCSfile$$Revision$: end of file */