f6b65a50459397f49a7705dba4014d11e62d6ade
[aaf/sshsm.git] / SoftHSMv2 / src / bin / win32 / getopt.h
1 /*-
2  * Copyright (c) 2000 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Dieter Baron and Thomas Klausner.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *        This product includes software developed by the NetBSD
19  *        Foundation, Inc. and its contributors.
20  * 4. Neither the name of The NetBSD Foundation nor the names of its
21  *    contributors may be used to endorse or promote products derived
22  *    from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #ifndef _GETOPT_H_
38 #define _GETOPT_H_
39
40 #ifdef _WIN32
41 /* from <sys/cdefs.h> */
42 # ifdef  __cplusplus
43 #  define __BEGIN_DECLS  extern "C" {
44 #  define __END_DECLS    }
45 # else
46 #  define __BEGIN_DECLS
47 #  define __END_DECLS
48 # endif
49 # define __P(args)      args
50 #endif
51
52 /*#ifndef _WIN32
53 #include <sys/cdefs.h>
54 #include <unistd.h>
55 #endif*/
56
57 /*
58  * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
59  */
60 #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
61 #define no_argument        0
62 #define required_argument  1
63 #define optional_argument  2
64
65 struct option {
66         /* name of long option */
67         const char *name;
68         /*
69          * one of no_argument, required_argument, and optional_argument:
70          * whether option takes an argument
71          */
72         int has_arg;
73         /* if not NULL, set *flag to val when option found */
74         int *flag;
75         /* if flag not NULL, value to set *flag to; else return value */
76         int val;
77 };
78
79 __BEGIN_DECLS
80 int getopt_long __P((int, char * const *, const char *,
81     const struct option *, int *));
82 __END_DECLS
83 #endif
84
85 #ifdef _WIN32
86 /* These are global getopt variables */
87 __BEGIN_DECLS
88
89 extern int   opterr,   /* if error message should be printed */
90              optind,   /* index into parent argv vector */
91              optopt,   /* character checked for validity */
92              optreset; /* reset getopt */
93 extern char* optarg;   /* argument associated with option */
94
95 /* Original getopt */
96 int getopt __P((int, char * const *, const char *));
97
98 __END_DECLS
99 #endif
100  
101 #endif /* !_GETOPT_H_ */