xref: /aosp_15_r20/external/sg3_utils/getopt_long/getopt.h (revision 44704f698541f6367e81f991ef8bb54ccbf3fc18)
1*44704f69SBart Van Assche /*	$NetBSD: getopt.h,v 1.7 2005/02/03 04:39:32 perry Exp $	*/
2*44704f69SBart Van Assche 
3*44704f69SBart Van Assche /*-
4*44704f69SBart Van Assche  * Copyright (c) 2000 The NetBSD Foundation, Inc.
5*44704f69SBart Van Assche  * All rights reserved.
6*44704f69SBart Van Assche  *
7*44704f69SBart Van Assche  * This code is derived from software contributed to The NetBSD Foundation
8*44704f69SBart Van Assche  * by Dieter Baron and Thomas Klausner.
9*44704f69SBart Van Assche  *
10*44704f69SBart Van Assche  * Redistribution and use in source and binary forms, with or without
11*44704f69SBart Van Assche  * modification, are permitted provided that the following conditions
12*44704f69SBart Van Assche  * are met:
13*44704f69SBart Van Assche  * 1. Redistributions of source code must retain the above copyright
14*44704f69SBart Van Assche  *    notice, this list of conditions and the following disclaimer.
15*44704f69SBart Van Assche  * 2. Redistributions in binary form must reproduce the above copyright
16*44704f69SBart Van Assche  *    notice, this list of conditions and the following disclaimer in the
17*44704f69SBart Van Assche  *    documentation and/or other materials provided with the distribution.
18*44704f69SBart Van Assche  * 3. All advertising materials mentioning features or use of this software
19*44704f69SBart Van Assche  *    must display the following acknowledgement:
20*44704f69SBart Van Assche  *        This product includes software developed by the NetBSD
21*44704f69SBart Van Assche  *        Foundation, Inc. and its contributors.
22*44704f69SBart Van Assche  * 4. Neither the name of The NetBSD Foundation nor the names of its
23*44704f69SBart Van Assche  *    contributors may be used to endorse or promote products derived
24*44704f69SBart Van Assche  *    from this software without specific prior written permission.
25*44704f69SBart Van Assche  *
26*44704f69SBart Van Assche  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27*44704f69SBart Van Assche  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28*44704f69SBart Van Assche  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29*44704f69SBart Van Assche  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30*44704f69SBart Van Assche  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31*44704f69SBart Van Assche  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32*44704f69SBart Van Assche  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33*44704f69SBart Van Assche  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34*44704f69SBart Van Assche  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35*44704f69SBart Van Assche  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36*44704f69SBart Van Assche  * POSSIBILITY OF SUCH DAMAGE.
37*44704f69SBart Van Assche  */
38*44704f69SBart Van Assche 
39*44704f69SBart Van Assche /*
40*44704f69SBart Van Assche  * modified May 12, 2005 by Jim Basney <[email protected]>
41*44704f69SBart Van Assche  *
42*44704f69SBart Van Assche  * removed #include of non-POSIX <sys/cdefs.h> and <sys/featuretest.h>
43*44704f69SBart Van Assche  * removed references to _NETBSD_SOURCE and HAVE_NBTOOL_CONFIG_H
44*44704f69SBart Van Assche  * added #if !HAVE_GETOPT_LONG
45*44704f69SBart Van Assche  * removed __BEGIN_DECLS and __END_DECLS
46*44704f69SBart Van Assche  */
47*44704f69SBart Van Assche 
48*44704f69SBart Van Assche #ifndef _MYPROXY_GETOPT_H_
49*44704f69SBart Van Assche #define _MYPROXY_GETOPT_H_
50*44704f69SBart Van Assche 
51*44704f69SBart Van Assche #if !HAVE_GETOPT_LONG
52*44704f69SBart Van Assche 
53*44704f69SBart Van Assche #include <unistd.h>
54*44704f69SBart Van Assche 
55*44704f69SBart Van Assche /*
56*44704f69SBart Van Assche  * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
57*44704f69SBart Van Assche  */
58*44704f69SBart Van Assche #define no_argument        0
59*44704f69SBart Van Assche #define required_argument  1
60*44704f69SBart Van Assche #define optional_argument  2
61*44704f69SBart Van Assche 
62*44704f69SBart Van Assche extern char *optarg;
63*44704f69SBart Van Assche extern int optind;
64*44704f69SBart Van Assche extern int optopt;
65*44704f69SBart Van Assche extern int opterr;
66*44704f69SBart Van Assche 
67*44704f69SBart Van Assche struct option {
68*44704f69SBart Van Assche 	/* name of long option */
69*44704f69SBart Van Assche 	const char *name;
70*44704f69SBart Van Assche 	/*
71*44704f69SBart Van Assche 	 * one of no_argument, required_argument, and optional_argument:
72*44704f69SBart Van Assche 	 * whether option takes an argument
73*44704f69SBart Van Assche 	 */
74*44704f69SBart Van Assche 	int has_arg;
75*44704f69SBart Van Assche 	/* if not NULL, set *flag to val when option found */
76*44704f69SBart Van Assche 	int *flag;
77*44704f69SBart Van Assche 	/* if flag not NULL, value to set *flag to; else return value */
78*44704f69SBart Van Assche 	int val;
79*44704f69SBart Van Assche };
80*44704f69SBart Van Assche 
81*44704f69SBart Van Assche int getopt_long(int, char * const *, const char *,
82*44704f69SBart Van Assche     const struct option *, int *);
83*44704f69SBart Van Assche 
84*44704f69SBart Van Assche #endif /* !HAVE_GETOPT_LONG */
85*44704f69SBart Van Assche 
86*44704f69SBart Van Assche #endif /* !_MYPROXY_GETOPT_H_ */
87