| 1 | /* getopt.h,v 1.6 2004/09/14 22:27:33 bird Exp */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * FreeBSD 5.2
|
|---|
| 4 | * @changed bird: Added one GNU api from libiberty.
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
|
|---|
| 8 | /* $FreeBSD: src/include/getopt.h,v 1.6 2004/02/24 08:09:20 ache Exp $ */
|
|---|
| 9 |
|
|---|
| 10 | /*-
|
|---|
| 11 | * Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|---|
| 12 | * All rights reserved.
|
|---|
| 13 | *
|
|---|
| 14 | * This code is derived from software contributed to The NetBSD Foundation
|
|---|
| 15 | * by Dieter Baron and Thomas Klausner.
|
|---|
| 16 | *
|
|---|
| 17 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 18 | * modification, are permitted provided that the following conditions
|
|---|
| 19 | * are met:
|
|---|
| 20 | * 1. Redistributions of source code must retain the above copyright
|
|---|
| 21 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 22 | * 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 23 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 24 | * documentation and/or other materials provided with the distribution.
|
|---|
| 25 | * 3. All advertising materials mentioning features or use of this software
|
|---|
| 26 | * must display the following acknowledgement:
|
|---|
| 27 | * This product includes software developed by the NetBSD
|
|---|
| 28 | * Foundation, Inc. and its contributors.
|
|---|
| 29 | * 4. Neither the name of The NetBSD Foundation nor the names of its
|
|---|
| 30 | * contributors may be used to endorse or promote products derived
|
|---|
| 31 | * from this software without specific prior written permission.
|
|---|
| 32 | *
|
|---|
| 33 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|---|
| 34 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|---|
| 35 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|---|
| 36 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|---|
| 37 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|---|
| 38 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|---|
| 39 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|---|
| 40 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|---|
| 41 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|---|
| 42 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|---|
| 43 | * POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 44 | */
|
|---|
| 45 |
|
|---|
| 46 | #ifndef _GETOPT_H_
|
|---|
| 47 | #define _GETOPT_H_
|
|---|
| 48 |
|
|---|
| 49 | #include <sys/cdefs.h>
|
|---|
| 50 |
|
|---|
| 51 | /*
|
|---|
| 52 | * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
|
|---|
| 53 | * getopt() is declared here too for GNU programs.
|
|---|
| 54 | */
|
|---|
| 55 | #define no_argument 0
|
|---|
| 56 | #define required_argument 1
|
|---|
| 57 | #define optional_argument 2
|
|---|
| 58 |
|
|---|
| 59 | struct option {
|
|---|
| 60 | /* name of long option */
|
|---|
| 61 | const char *name;
|
|---|
| 62 | /*
|
|---|
| 63 | * one of no_argument, required_argument, and optional_argument:
|
|---|
| 64 | * whether option takes an argument
|
|---|
| 65 | */
|
|---|
| 66 | int has_arg;
|
|---|
| 67 | /* if not NULL, set *flag to val when option found */
|
|---|
| 68 | int *flag;
|
|---|
| 69 | /* if flag not NULL, value to set *flag to; else return value */
|
|---|
| 70 | int val;
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | __BEGIN_DECLS
|
|---|
| 74 | int getopt_long(int, char * const *, const char *,
|
|---|
| 75 | const struct option *, int *);
|
|---|
| 76 | int getopt_long_only(int, char * const *, const char *,
|
|---|
| 77 | const struct option *, int *);
|
|---|
| 78 | #ifndef _GETOPT_DECLARED
|
|---|
| 79 | #define _GETOPT_DECLARED
|
|---|
| 80 | int getopt(int, char * const [], const char *);
|
|---|
| 81 |
|
|---|
| 82 | extern char *optarg; /* getopt(3) external variables */
|
|---|
| 83 | extern int optind, opterr, optopt;
|
|---|
| 84 | #endif
|
|---|
| 85 | #ifndef _OPTRESET_DECLARED
|
|---|
| 86 | #define _OPTRESET_DECLARED
|
|---|
| 87 | extern int optreset; /* getopt(3) external variable */
|
|---|
| 88 | #endif
|
|---|
| 89 |
|
|---|
| 90 | /* bird - start: this is provided thru libiberty. */
|
|---|
| 91 | int _getopt_internal __P((int, char *const *, const char *,
|
|---|
| 92 | const struct option *, int *, int));
|
|---|
| 93 | /* bird - end */
|
|---|
| 94 |
|
|---|
| 95 | __END_DECLS
|
|---|
| 96 |
|
|---|
| 97 | #endif /* !_GETOPT_H_ */
|
|---|