1*05b00f60SXin Li /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ 2*05b00f60SXin Li /* $FreeBSD$ */ 3*05b00f60SXin Li 4*05b00f60SXin Li /*- 5*05b00f60SXin Li * Copyright (c) 2000 The NetBSD Foundation, Inc. 6*05b00f60SXin Li * All rights reserved. 7*05b00f60SXin Li * 8*05b00f60SXin Li * This code is derived from software contributed to The NetBSD Foundation 9*05b00f60SXin Li * by Dieter Baron and Thomas Klausner. 10*05b00f60SXin Li * 11*05b00f60SXin Li * Redistribution and use in source and binary forms, with or without 12*05b00f60SXin Li * modification, are permitted provided that the following conditions 13*05b00f60SXin Li * are met: 14*05b00f60SXin Li * 1. Redistributions of source code must retain the above copyright 15*05b00f60SXin Li * notice, this list of conditions and the following disclaimer. 16*05b00f60SXin Li * 2. Redistributions in binary form must reproduce the above copyright 17*05b00f60SXin Li * notice, this list of conditions and the following disclaimer in the 18*05b00f60SXin Li * documentation and/or other materials provided with the distribution. 19*05b00f60SXin Li * 20*05b00f60SXin Li * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21*05b00f60SXin Li * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22*05b00f60SXin Li * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*05b00f60SXin Li * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24*05b00f60SXin Li * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25*05b00f60SXin Li * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26*05b00f60SXin Li * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27*05b00f60SXin Li * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28*05b00f60SXin Li * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29*05b00f60SXin Li * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30*05b00f60SXin Li * POSSIBILITY OF SUCH DAMAGE. 31*05b00f60SXin Li */ 32*05b00f60SXin Li 33*05b00f60SXin Li #ifndef ND_GETOPT_LONG_H_ 34*05b00f60SXin Li #define ND_GETOPT_LONG_H_ 35*05b00f60SXin Li 36*05b00f60SXin Li /* 37*05b00f60SXin Li * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension. 38*05b00f60SXin Li * getopt() is declared here too for GNU programs. 39*05b00f60SXin Li */ 40*05b00f60SXin Li #define no_argument 0 41*05b00f60SXin Li #define required_argument 1 42*05b00f60SXin Li #define optional_argument 2 43*05b00f60SXin Li 44*05b00f60SXin Li struct option { 45*05b00f60SXin Li /* name of long option */ 46*05b00f60SXin Li const char *name; 47*05b00f60SXin Li /* 48*05b00f60SXin Li * one of no_argument, required_argument, and optional_argument: 49*05b00f60SXin Li * whether option takes an argument 50*05b00f60SXin Li */ 51*05b00f60SXin Li int has_arg; 52*05b00f60SXin Li /* if not NULL, set *flag to val when option found */ 53*05b00f60SXin Li int *flag; 54*05b00f60SXin Li /* if flag not NULL, value to set *flag to; else return value */ 55*05b00f60SXin Li int val; 56*05b00f60SXin Li }; 57*05b00f60SXin Li 58*05b00f60SXin Li int getopt_long(int, char * const *, const char *, 59*05b00f60SXin Li const struct option *, int *); 60*05b00f60SXin Li int getopt_long_only(int, char * const *, const char *, 61*05b00f60SXin Li const struct option *, int *); 62*05b00f60SXin Li 63*05b00f60SXin Li extern char *optarg; /* getopt(3) external variables */ 64*05b00f60SXin Li extern int optind, opterr, optopt; 65*05b00f60SXin Li 66*05b00f60SXin Li #endif /* ! ND_GETOPT_LONG_H_ */ 67