1284194Sdelphij/* $NetBSD: getopt.h,v 1.8 2007/11/06 19:21:18 christos Exp $ */ 2284194Sdelphij 3284194Sdelphij/*- 4284194Sdelphij * Copyright (c) 2000 The NetBSD Foundation, Inc. 5284194Sdelphij * All rights reserved. 6284194Sdelphij * 7284194Sdelphij * This code is derived from software contributed to The NetBSD Foundation 8284194Sdelphij * by Dieter Baron and Thomas Klausner. 9284194Sdelphij * 10284194Sdelphij * Redistribution and use in source and binary forms, with or without 11284194Sdelphij * modification, are permitted provided that the following conditions 12284194Sdelphij * are met: 13284194Sdelphij * 1. Redistributions of source code must retain the above copyright 14284194Sdelphij * notice, this list of conditions and the following disclaimer. 15284194Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 16284194Sdelphij * notice, this list of conditions and the following disclaimer in the 17284194Sdelphij * documentation and/or other materials provided with the distribution. 18284194Sdelphij * 3. All advertising materials mentioning features or use of this software 19284194Sdelphij * must display the following acknowledgement: 20284194Sdelphij * This product includes software developed by the NetBSD 21284194Sdelphij * Foundation, Inc. and its contributors. 22284194Sdelphij * 4. Neither the name of The NetBSD Foundation nor the names of its 23284194Sdelphij * contributors may be used to endorse or promote products derived 24284194Sdelphij * from this software without specific prior written permission. 25284194Sdelphij * 26284194Sdelphij * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27284194Sdelphij * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28284194Sdelphij * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29284194Sdelphij * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30284194Sdelphij * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31284194Sdelphij * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32284194Sdelphij * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33284194Sdelphij * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34284194Sdelphij * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35284194Sdelphij * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36284194Sdelphij * POSSIBILITY OF SUCH DAMAGE. 37284194Sdelphij */ 38284194Sdelphij 39284194Sdelphij#ifndef _GETOPT_H_ 40284194Sdelphij#define _GETOPT_H_ 41284194Sdelphij 42284194Sdelphij#include <unistd.h> 43284194Sdelphij 44284194Sdelphij/* 45284194Sdelphij * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions 46284194Sdelphij */ 47284194Sdelphij#define no_argument 0 48284194Sdelphij#define required_argument 1 49284194Sdelphij#define optional_argument 2 50284194Sdelphij 51284194Sdelphijstruct option { 52284194Sdelphij /* name of long option */ 53284194Sdelphij const char *name; 54284194Sdelphij /* 55284194Sdelphij * one of no_argument, required_argument, and optional_argument: 56284194Sdelphij * whether option takes an argument 57284194Sdelphij */ 58284194Sdelphij int has_arg; 59284194Sdelphij /* if not NULL, set *flag to val when option found */ 60284194Sdelphij int *flag; 61284194Sdelphij /* if flag not NULL, value to set *flag to; else return value */ 62284194Sdelphij int val; 63284194Sdelphij}; 64284194Sdelphij 65284194Sdelphijint getopt_long(int, char * const *, const char *, 66284194Sdelphij const struct option *, int *); 67284194Sdelphij 68284194Sdelphij#endif /* !_GETOPT_H_ */ 69