Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

bsd-getopt-long.h

Go to the documentation of this file.
00001 /* $Id: bsd-getopt-long.h,v 1.1 2005/09/12 19:48:26 vern Exp $ */
00002 
00003 /*    $OpenBSD: getopt_long.c,v 1.13 2003/06/03 01:52:40 millert Exp $    */
00004 /*    $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $    */
00005 
00006 /*
00007  * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
00008  *
00009  * Permission to use, copy, modify, and distribute this software for any
00010  * purpose with or without fee is hereby granted, provided that the above
00011  * copyright notice and this permission notice appear in all copies.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
00014  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
00015  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
00016  * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00017  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
00018  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00019  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00020  */
00021 /*-
00022  * Copyright (c) 2000 The NetBSD Foundation, Inc.
00023  * All rights reserved.
00024  *
00025  * This code is derived from software contributed to The NetBSD Foundation
00026  * by Dieter Baron and Thomas Klausner.
00027  *
00028  * Redistribution and use in source and binary forms, with or without
00029  * modification, are permitted provided that the following conditions
00030  * are met:
00031  * 1. Redistributions of source code must retain the above copyright
00032  *    notice, this list of conditions and the following disclaimer.
00033  * 2. Redistributions in binary form must reproduce the above copyright
00034  *    notice, this list of conditions and the following disclaimer in the
00035  *    documentation and/or other materials provided with the distribution.
00036  * 3. All advertising materials mentioning features or use of this software
00037  *    must display the following acknowledgement:
00038  *        This product includes software developed by the NetBSD
00039  *        Foundation, Inc. and its contributors.
00040  * 4. Neither the name of The NetBSD Foundation nor the names of its
00041  *    contributors may be used to endorse or promote products derived
00042  *    from this software without specific prior written permission.
00043  *
00044  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
00045  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00046  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00047  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
00048  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00049  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00050  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00051  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00052  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00053  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00054  * POSSIBILITY OF SUCH DAMAGE.
00055  */
00056 
00057 #ifndef __BSD_GETOPT_LONG_H__
00058 #define __BSD_GETOPT_LONG_H__
00059 
00060 #ifndef HAVE_GETOPT_LONG
00061 
00062 /*
00063  * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
00064  */
00065 # ifndef no_argument
00066 #  define no_argument        0
00067 # endif
00068 # ifndef required_argument
00069 #  define required_argument  1
00070 # endif
00071 # ifndef optional_argument
00072 #  define optional_argument  2
00073 # endif
00074 
00075 struct pure_option {
00076     /* name of long option */
00077     const char *name;
00078     /*
00079      * one of no_argument, required_argument, and optional_argument:
00080      * whether option takes an argument
00081      */
00082     int has_arg;
00083     /* if not NULL, set *flag to val when option found */
00084     int *flag;
00085     /* if flag not NULL, value to set *flag to; else return value */
00086     int val;
00087 };
00088 
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092 
00093 int pure_getopt_long(int nargc, char * const *nargv, const char *options,
00094                      const struct pure_option *long_options, int *idx);
00095 
00096 int pure_getopt_long_only(int nargc, char * const *nargv,
00097                           const char *options,
00098                           const struct pure_option *long_options,
00099                           int *idx);
00100 
00101 int pure_getopt(int nargc, char * const *nargv, const char *options);
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 /* prefix+macros just to avoid clashes with existing getopt() implementations */
00108 
00109 # ifndef IN_GETOPT_LONG_C
00110 #  undef option
00111 #  define option pure_option
00112 #  undef getopt_long
00113 #  define getopt_long(A, B, C, D, E) pure_getopt_long(A, B, C, D, E)
00114 #  undef getopt_long_only
00115 #  define getopt_long_only(A, B, C, D, E) pure_getopt_long_only(A, B, C, D, E)
00116 #  undef getopt
00117 #  define getopt(A, B, C) pure_getopt(A, B, C)
00118 #  undef optarg
00119 #  define optarg pure_optarg
00120 #  undef opterr
00121 #  define opterr pure_opterr
00122 #  undef optind
00123 #  define optind pure_optind
00124 #  undef optopt
00125 #  define optopt pure_optopt
00126 #  undef optreset
00127 #  define optreset pure_optreset
00128 # endif
00129 
00130 #endif
00131 
00132 #endif

Generated on Wed Sep 14 02:55:58 2005 for bro_docs by doxygen 1.3.5