1255670Sdes/*	$OpenBSD: getopt.h,v 1.2 2008/06/26 05:42:04 ray Exp $	*/
2255670Sdes/*	$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $	*/
3255670Sdes
4255670Sdes/*-
5255670Sdes * Copyright (c) 2000 The NetBSD Foundation, Inc.
6255670Sdes * All rights reserved.
7255670Sdes *
8255670Sdes * This code is derived from software contributed to The NetBSD Foundation
9255670Sdes * by Dieter Baron and Thomas Klausner.
10255670Sdes *
11255670Sdes * Redistribution and use in source and binary forms, with or without
12255670Sdes * modification, are permitted provided that the following conditions
13255670Sdes * are met:
14255670Sdes * 1. Redistributions of source code must retain the above copyright
15255670Sdes *    notice, this list of conditions and the following disclaimer.
16255670Sdes * 2. Redistributions in binary form must reproduce the above copyright
17255670Sdes *    notice, this list of conditions and the following disclaimer in the
18255670Sdes *    documentation and/or other materials provided with the distribution.
19255670Sdes *
20255670Sdes * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21255670Sdes * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22255670Sdes * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23255670Sdes * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24255670Sdes * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25255670Sdes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26255670Sdes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27255670Sdes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28255670Sdes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29255670Sdes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30255670Sdes * POSSIBILITY OF SUCH DAMAGE.
31255670Sdes */
32255670Sdes
33255670Sdes#ifndef _GETOPT_H_
34255670Sdes#define _GETOPT_H_
35255670Sdes
36255670Sdes/*
37255670Sdes * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
38255670Sdes */
39255670Sdes#define no_argument        0
40255670Sdes#define required_argument  1
41255670Sdes#define optional_argument  2
42255670Sdes
43255670Sdesstruct option {
44255670Sdes	/* name of long option */
45255670Sdes	const char *name;
46255670Sdes	/*
47255670Sdes	 * one of no_argument, required_argument, and optional_argument:
48255670Sdes	 * whether option takes an argument
49255670Sdes	 */
50255670Sdes	int has_arg;
51255670Sdes	/* if not NULL, set *flag to val when option found */
52255670Sdes	int *flag;
53255670Sdes	/* if flag not NULL, value to set *flag to; else return value */
54255670Sdes	int val;
55255670Sdes};
56255670Sdes
57255670Sdesint	 getopt_long(int, char * const *, const char *,
58255670Sdes	    const struct option *, int *);
59255670Sdesint	 getopt_long_only(int, char * const *, const char *,
60255670Sdes	    const struct option *, int *);
61255670Sdes#ifndef _GETOPT_DEFINED_
62255670Sdes#define _GETOPT_DEFINED_
63255670Sdesint	 getopt(int, char * const *, const char *);
64255670Sdesint	 getsubopt(char **, char * const *, char **);
65255670Sdes
66255670Sdesextern   char *optarg;                  /* getopt(3) external variables */
67255670Sdesextern   int opterr;
68255670Sdesextern   int optind;
69255670Sdesextern   int optopt;
70255670Sdesextern   int optreset;
71255670Sdesextern   char *suboptarg;               /* getsubopt(3) external variable */
72255670Sdes#endif
73255670Sdes
74255670Sdes#endif /* !_GETOPT_H_ */
75