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