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