1276761Sdelphij/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ 2313537Sglebius/* $FreeBSD: stable/11/contrib/tcpdump/getopt_long.h 276788 2015-01-07 19:55:18Z delphij $ */ 3276761Sdelphij 4276761Sdelphij/*- 5276761Sdelphij * Copyright (c) 2000 The NetBSD Foundation, Inc. 6276761Sdelphij * All rights reserved. 7276761Sdelphij * 8276761Sdelphij * This code is derived from software contributed to The NetBSD Foundation 9276761Sdelphij * by Dieter Baron and Thomas Klausner. 10276761Sdelphij * 11276761Sdelphij * Redistribution and use in source and binary forms, with or without 12276761Sdelphij * modification, are permitted provided that the following conditions 13276761Sdelphij * are met: 14276761Sdelphij * 1. Redistributions of source code must retain the above copyright 15276761Sdelphij * notice, this list of conditions and the following disclaimer. 16276761Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 17276761Sdelphij * notice, this list of conditions and the following disclaimer in the 18276761Sdelphij * documentation and/or other materials provided with the distribution. 19276761Sdelphij * 20276761Sdelphij * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21276761Sdelphij * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22276761Sdelphij * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23276761Sdelphij * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24276761Sdelphij * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25276761Sdelphij * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26276761Sdelphij * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27276761Sdelphij * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28276761Sdelphij * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29276761Sdelphij * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30276761Sdelphij * POSSIBILITY OF SUCH DAMAGE. 31276761Sdelphij */ 32276761Sdelphij 33276761Sdelphij#ifndef _GETOPT_LONG_H_ 34276761Sdelphij#define _GETOPT_LONG_H_ 35276761Sdelphij 36276761Sdelphij/* 37276761Sdelphij * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension. 38276761Sdelphij * getopt() is declared here too for GNU programs. 39276761Sdelphij */ 40276761Sdelphij#define no_argument 0 41276761Sdelphij#define required_argument 1 42276761Sdelphij#define optional_argument 2 43276761Sdelphij 44276761Sdelphijstruct option { 45276761Sdelphij /* name of long option */ 46276761Sdelphij const char *name; 47276761Sdelphij /* 48276761Sdelphij * one of no_argument, required_argument, and optional_argument: 49276761Sdelphij * whether option takes an argument 50276761Sdelphij */ 51276761Sdelphij int has_arg; 52276761Sdelphij /* if not NULL, set *flag to val when option found */ 53276761Sdelphij int *flag; 54276761Sdelphij /* if flag not NULL, value to set *flag to; else return value */ 55276761Sdelphij int val; 56276761Sdelphij}; 57276761Sdelphij 58276761Sdelphijint getopt_long(int, char * const *, const char *, 59276761Sdelphij const struct option *, int *); 60276761Sdelphijint getopt_long_only(int, char * const *, const char *, 61276761Sdelphij const struct option *, int *); 62276761Sdelphij 63276761Sdelphijextern char *optarg; /* getopt(3) external variables */ 64276761Sdelphijextern int optind, opterr, optopt; 65276761Sdelphij 66276761Sdelphij#endif /* !_GETOPT_LONG_H_ */ 67