getopt.h revision 126141
168349Sobrien/*	$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $	*/
2330569Sgordon/*	$FreeBSD: head/include/getopt.h 126141 2004-02-23 04:17:59Z ache $ */
368349Sobrien
468349Sobrien/*-
568349Sobrien * Copyright (c) 2000 The NetBSD Foundation, Inc.
668349Sobrien * All rights reserved.
768349Sobrien *
868349Sobrien * This code is derived from software contributed to The NetBSD Foundation
968349Sobrien * by Dieter Baron and Thomas Klausner.
1068349Sobrien *
11186690Sobrien * Redistribution and use in source and binary forms, with or without
1268349Sobrien * modification, are permitted provided that the following conditions
13186690Sobrien * are met:
1468349Sobrien * 1. Redistributions of source code must retain the above copyright
15234250Sobrien *    notice, this list of conditions and the following disclaimer.
16234250Sobrien * 2. Redistributions in binary form must reproduce the above copyright
17234250Sobrien *    notice, this list of conditions and the following disclaimer in the
18234250Sobrien *    documentation and/or other materials provided with the distribution.
19234250Sobrien * 3. All advertising materials mentioning features or use of this software
2068349Sobrien *    must display the following acknowledgement:
2168349Sobrien *        This product includes software developed by the NetBSD
2268349Sobrien *        Foundation, Inc. and its contributors.
2368349Sobrien * 4. Neither the name of The NetBSD Foundation nor the names of its
2468349Sobrien *    contributors may be used to endorse or promote products derived
2568349Sobrien *    from this software without specific prior written permission.
2668349Sobrien *
2768349Sobrien * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2868349Sobrien * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2968349Sobrien * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3068349Sobrien * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
3168349Sobrien * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32186690Sobrien * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3368349Sobrien * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34186690Sobrien * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3568349Sobrien * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3668349Sobrien * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3768349Sobrien * POSSIBILITY OF SUCH DAMAGE.
3868349Sobrien */
3968349Sobrien
40267843Sdelphij#ifndef _GETOPT_H_
41267843Sdelphij#define _GETOPT_H_
42267843Sdelphij
43267843Sdelphij#include <sys/cdefs.h>
44267843Sdelphij
45267843Sdelphij/*
46267843Sdelphij * GNU-like getopt_long() & getopt() for GNU programs.
47267843Sdelphij */
48267843Sdelphij#define no_argument        0
49267843Sdelphij#define required_argument  1
50267843Sdelphij#define optional_argument  2
51267843Sdelphij
52267843Sdelphijstruct option {
53267843Sdelphij	/* name of long option */
54267843Sdelphij	const char *name;
55267843Sdelphij	/*
56267843Sdelphij	 * one of no_argument, required_argument, and optional_argument:
57267843Sdelphij	 * whether option takes an argument
58267843Sdelphij	 */
59267843Sdelphij	int has_arg;
60267843Sdelphij	/* if not NULL, set *flag to val when option found */
61267843Sdelphij	int *flag;
62267843Sdelphij	/* if flag not NULL, value to set *flag to; else return value */
63267843Sdelphij	int val;
64267843Sdelphij};
65267843Sdelphij
66267843Sdelphij__BEGIN_DECLS
67267843Sdelphijint	getopt_long(int, char * const *, const char *,
68267843Sdelphij	const struct option *, int *);
69267843Sdelphij#ifndef _GETOPT_DECLARED
70267843Sdelphij#define	_GETOPT_DECLARED
71267843Sdelphijint	 getopt(int, char * const [], const char *);
72267843Sdelphij
73267843Sdelphijextern char *optarg;			/* getopt(3) external variables */
74267843Sdelphijextern int optind, opterr, optopt;
75267843Sdelphij#endif /* _GETOPT_DECLARED */
76267843Sdelphij__END_DECLS
77267843Sdelphij
78267843Sdelphij#endif /* !_GETOPT_H_ */
79267843Sdelphij