Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/compat/getopt/getopt.h
1201 views
1
/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */
2
/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */
3
/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
4
5
/*-
6
* Copyright (c) 2000 The NetBSD Foundation, Inc.
7
* All rights reserved.
8
*
9
* This code is derived from software contributed to The NetBSD Foundation
10
* by Dieter Baron and Thomas Klausner.
11
*
12
* Redistribution and use in source and binary forms, with or without
13
* modification, are permitted provided that the following conditions
14
* are met:
15
* 1. Redistributions of source code must retain the above copyright
16
* notice, this list of conditions and the following disclaimer.
17
* 2. Redistributions in binary form must reproduce the above copyright
18
* notice, this list of conditions and the following disclaimer in the
19
* documentation and/or other materials provided with the distribution.
20
* 3. All advertising materials mentioning features or use of this software
21
* must display the following acknowledgement:
22
* This product includes software developed by the NetBSD
23
* Foundation, Inc. and its contributors.
24
* 4. Neither the name of The NetBSD Foundation nor the names of its
25
* contributors may be used to endorse or promote products derived
26
* from this software without specific prior written permission.
27
*
28
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
* POSSIBILITY OF SUCH DAMAGE.
39
*/
40
41
#ifndef _GETOPT_H_
42
#define _GETOPT_H_
43
44
#if 0
45
#include <sys/cdefs.h>
46
#endif
47
48
/*
49
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
50
*/
51
#define no_argument 0
52
#define required_argument 1
53
#define optional_argument 2
54
55
struct option {
56
/* name of long option */
57
const char *name;
58
/*
59
* one of no_argument, required_argument, and optional_argument:
60
* whether option takes an argument
61
*/
62
int has_arg;
63
/* if not NULL, set *flag to val when option found */
64
int *flag;
65
/* if flag not NULL, value to set *flag to; else return value */
66
int val;
67
};
68
69
#ifdef __cplusplus
70
extern "C" {
71
#endif
72
73
int getopt_long(int, char * const *, const char *,
74
const struct option *, int *);
75
int getopt_long_only(int, char * const *, const char *,
76
const struct option *, int *);
77
#ifndef _GETOPT_DEFINED
78
#define _GETOPT_DEFINED
79
int getopt(int, char * const *, const char *);
80
int getsubopt(char **, char * const *, char **);
81
82
extern char *optarg; /* getopt(3) external variables */
83
extern int opterr;
84
extern int optind;
85
extern int optopt;
86
extern int optreset;
87
extern char *suboptarg; /* getsubopt(3) external variable */
88
#endif /* _GETOPT_DEFINED */
89
90
#ifdef __cplusplus
91
}
92
#endif
93
#endif /* !_GETOPT_H_ */
94
95