1104128Seric/*	$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $	*/
2104128Seric/*	$FreeBSD$ */
3104128Seric
4104128Seric/*-
5104128Seric * Copyright (c) 2000 The NetBSD Foundation, Inc.
6104128Seric * All rights reserved.
7104128Seric *
8104128Seric * This code is derived from software contributed to The NetBSD Foundation
9104128Seric * by Dieter Baron and Thomas Klausner.
10104128Seric *
11104128Seric * Redistribution and use in source and binary forms, with or without
12104128Seric * modification, are permitted provided that the following conditions
13104128Seric * are met:
14104128Seric * 1. Redistributions of source code must retain the above copyright
15104128Seric *    notice, this list of conditions and the following disclaimer.
16104128Seric * 2. Redistributions in binary form must reproduce the above copyright
17104128Seric *    notice, this list of conditions and the following disclaimer in the
18104128Seric *    documentation and/or other materials provided with the distribution.
19104128Seric *
20104128Seric * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21104128Seric * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22104128Seric * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23104128Seric * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24104128Seric * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25104128Seric * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26104128Seric * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27104128Seric * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28104128Seric * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29104128Seric * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30104128Seric * POSSIBILITY OF SUCH DAMAGE.
31104128Seric */
32104128Seric
33104128Seric#ifndef _GETOPT_H_
34104128Seric#define _GETOPT_H_
35104128Seric
36104128Seric#include <sys/cdefs.h>
37104128Seric
38104128Seric/*
39126190Sache * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
40126155Sache * getopt() is declared here too for GNU programs.
41104128Seric */
42104128Seric#define no_argument        0
43104128Seric#define required_argument  1
44104128Seric#define optional_argument  2
45104128Seric
46104128Sericstruct option {
47104128Seric	/* name of long option */
48104128Seric	const char *name;
49104128Seric	/*
50104128Seric	 * one of no_argument, required_argument, and optional_argument:
51104128Seric	 * whether option takes an argument
52104128Seric	 */
53104128Seric	int has_arg;
54104128Seric	/* if not NULL, set *flag to val when option found */
55104128Seric	int *flag;
56104128Seric	/* if flag not NULL, value to set *flag to; else return value */
57104128Seric	int val;
58104128Seric};
59104128Seric
60104128Seric__BEGIN_DECLS
61126141Sacheint	getopt_long(int, char * const *, const char *,
62126141Sache	const struct option *, int *);
63126190Sacheint	getopt_long_only(int, char * const *, const char *,
64126190Sache	const struct option *, int *);
65126141Sache#ifndef _GETOPT_DECLARED
66126141Sache#define	_GETOPT_DECLARED
67126141Sacheint	 getopt(int, char * const [], const char *);
68126141Sache
69126141Sacheextern char *optarg;			/* getopt(3) external variables */
70126141Sacheextern int optind, opterr, optopt;
71126142Sache#endif
72126142Sache#ifndef _OPTRESET_DECLARED
73126142Sache#define	_OPTRESET_DECLARED
74126142Sacheextern int optreset;			/* getopt(3) external variable */
75126142Sache#endif
76104128Seric__END_DECLS
77104128Seric
78104128Seric#endif /* !_GETOPT_H_ */
79