1186690Sobrien/*	$NetBSD: getopt.h,v 1.8 2007/11/06 19:21:18 christos Exp $	*/
2186690Sobrien
3186690Sobrien/*-
4186690Sobrien * Copyright (c) 2000 The NetBSD Foundation, Inc.
5186690Sobrien * All rights reserved.
6186690Sobrien *
7186690Sobrien * This code is derived from software contributed to The NetBSD Foundation
8186690Sobrien * by Dieter Baron and Thomas Klausner.
9186690Sobrien *
10186690Sobrien * Redistribution and use in source and binary forms, with or without
11186690Sobrien * modification, are permitted provided that the following conditions
12186690Sobrien * are met:
13186690Sobrien * 1. Redistributions of source code must retain the above copyright
14186690Sobrien *    notice, this list of conditions and the following disclaimer.
15186690Sobrien * 2. Redistributions in binary form must reproduce the above copyright
16186690Sobrien *    notice, this list of conditions and the following disclaimer in the
17186690Sobrien *    documentation and/or other materials provided with the distribution.
18186690Sobrien * 3. All advertising materials mentioning features or use of this software
19186690Sobrien *    must display the following acknowledgement:
20186690Sobrien *        This product includes software developed by the NetBSD
21186690Sobrien *        Foundation, Inc. and its contributors.
22186690Sobrien * 4. Neither the name of The NetBSD Foundation nor the names of its
23186690Sobrien *    contributors may be used to endorse or promote products derived
24186690Sobrien *    from this software without specific prior written permission.
25186690Sobrien *
26186690Sobrien * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27186690Sobrien * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28186690Sobrien * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29186690Sobrien * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30186690Sobrien * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31186690Sobrien * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32186690Sobrien * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33186690Sobrien * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34186690Sobrien * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35186690Sobrien * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36186690Sobrien * POSSIBILITY OF SUCH DAMAGE.
37186690Sobrien */
38186690Sobrien
39186690Sobrien#ifndef _GETOPT_H_
40186690Sobrien#define _GETOPT_H_
41186690Sobrien
42186690Sobrien#include <unistd.h>
43186690Sobrien
44186690Sobrien/*
45186690Sobrien * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
46186690Sobrien */
47186690Sobrien#define no_argument        0
48186690Sobrien#define required_argument  1
49186690Sobrien#define optional_argument  2
50186690Sobrien
51186690Sobrienstruct option {
52186690Sobrien	/* name of long option */
53186690Sobrien	const char *name;
54186690Sobrien	/*
55186690Sobrien	 * one of no_argument, required_argument, and optional_argument:
56186690Sobrien	 * whether option takes an argument
57186690Sobrien	 */
58186690Sobrien	int has_arg;
59186690Sobrien	/* if not NULL, set *flag to val when option found */
60186690Sobrien	int *flag;
61186690Sobrien	/* if flag not NULL, value to set *flag to; else return value */
62186690Sobrien	int val;
63186690Sobrien};
64186690Sobrien
65186690Sobrienint getopt_long(int, char * const *, const char *,
66186690Sobrien    const struct option *, int *);
67186690Sobrien
68186690Sobrien#endif /* !_GETOPT_H_ */
69