getopt.h revision 126141
1104128Seric/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ 2104128Seric/* $FreeBSD: head/include/getopt.h 126141 2004-02-23 04:17:59Z ache $ */ 3104128Seric 4104128Seric/*- 5104128Seric * Copyright (c) 2000 The NetBSD Foundation, Inc. 6104128Seric * All rights reserved. 7104128Seric * 8104128Seric * This code is derived from software contributed to The NetBSD Foundation 9104128Seric * by Dieter Baron and Thomas Klausner. 10104128Seric * 11104128Seric * Redistribution and use in source and binary forms, with or without 12104128Seric * modification, are permitted provided that the following conditions 13104128Seric * are met: 14104128Seric * 1. Redistributions of source code must retain the above copyright 15104128Seric * notice, this list of conditions and the following disclaimer. 16104128Seric * 2. Redistributions in binary form must reproduce the above copyright 17104128Seric * notice, this list of conditions and the following disclaimer in the 18104128Seric * documentation and/or other materials provided with the distribution. 19104128Seric * 3. All advertising materials mentioning features or use of this software 20104128Seric * must display the following acknowledgement: 21104128Seric * This product includes software developed by the NetBSD 22104128Seric * Foundation, Inc. and its contributors. 23104128Seric * 4. Neither the name of The NetBSD Foundation nor the names of its 24104128Seric * contributors may be used to endorse or promote products derived 25104128Seric * from this software without specific prior written permission. 26104128Seric * 27104128Seric * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28104128Seric * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29104128Seric * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30104128Seric * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31104128Seric * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32104128Seric * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33104128Seric * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34104128Seric * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35104128Seric * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36104128Seric * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37104128Seric * POSSIBILITY OF SUCH DAMAGE. 38104128Seric */ 39104128Seric 40104128Seric#ifndef _GETOPT_H_ 41104128Seric#define _GETOPT_H_ 42104128Seric 43104128Seric#include <sys/cdefs.h> 44104128Seric 45104128Seric/* 46126141Sache * GNU-like getopt_long() & getopt() for GNU programs. 47104128Seric */ 48104128Seric#define no_argument 0 49104128Seric#define required_argument 1 50104128Seric#define optional_argument 2 51104128Seric 52104128Sericstruct option { 53104128Seric /* name of long option */ 54104128Seric const char *name; 55104128Seric /* 56104128Seric * one of no_argument, required_argument, and optional_argument: 57104128Seric * whether option takes an argument 58104128Seric */ 59104128Seric int has_arg; 60104128Seric /* if not NULL, set *flag to val when option found */ 61104128Seric int *flag; 62104128Seric /* if flag not NULL, value to set *flag to; else return value */ 63104128Seric int val; 64104128Seric}; 65104128Seric 66104128Seric__BEGIN_DECLS 67126141Sacheint getopt_long(int, char * const *, const char *, 68126141Sache const struct option *, int *); 69126141Sache#ifndef _GETOPT_DECLARED 70126141Sache#define _GETOPT_DECLARED 71126141Sacheint getopt(int, char * const [], const char *); 72126141Sache 73126141Sacheextern char *optarg; /* getopt(3) external variables */ 74126141Sacheextern int optind, opterr, optopt; 75126141Sache#endif /* _GETOPT_DECLARED */ 76104128Seric__END_DECLS 77104128Seric 78104128Seric#endif /* !_GETOPT_H_ */ 79