/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */1/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */2/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */34/*-5* Copyright (c) 2000 The NetBSD Foundation, Inc.6* All rights reserved.7*8* This code is derived from software contributed to The NetBSD Foundation9* by Dieter Baron and Thomas Klausner.10*11* Redistribution and use in source and binary forms, with or without12* modification, are permitted provided that the following conditions13* are met:14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions and the following disclaimer.16* 2. Redistributions in binary form must reproduce the above copyright17* notice, this list of conditions and the following disclaimer in the18* documentation and/or other materials provided with the distribution.19* 3. All advertising materials mentioning features or use of this software20* must display the following acknowledgement:21* This product includes software developed by the NetBSD22* Foundation, Inc. and its contributors.23* 4. Neither the name of The NetBSD Foundation nor the names of its24* contributors may be used to endorse or promote products derived25* from this software without specific prior written permission.26*27* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS28* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED29* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR30* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS31* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR32* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF33* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS34* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN35* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)36* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE37* POSSIBILITY OF SUCH DAMAGE.38*/3940#ifndef _GETOPT_H_41#define _GETOPT_H_4243#if 044#include <sys/cdefs.h>45#endif4647/*48* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions49*/50#define no_argument 051#define required_argument 152#define optional_argument 25354struct option {55/* name of long option */56const char *name;57/*58* one of no_argument, required_argument, and optional_argument:59* whether option takes an argument60*/61int has_arg;62/* if not NULL, set *flag to val when option found */63int *flag;64/* if flag not NULL, value to set *flag to; else return value */65int val;66};6768#ifdef __cplusplus69extern "C" {70#endif7172int getopt_long(int, char * const *, const char *,73const struct option *, int *);74int getopt_long_only(int, char * const *, const char *,75const struct option *, int *);76#ifndef _GETOPT_DEFINED77#define _GETOPT_DEFINED78int getopt(int, char * const *, const char *);79int getsubopt(char **, char * const *, char **);8081extern char *optarg; /* getopt(3) external variables */82extern int opterr;83extern int optind;84extern int optopt;85extern int optreset;86extern char *suboptarg; /* getsubopt(3) external variable */87#endif /* _GETOPT_DEFINED */8889#ifdef __cplusplus90}91#endif92#endif /* !_GETOPT_H_ */939495