getopt.h

Go to the documentation of this file.
00001 /*      $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $    */
00002 /*      $FreeBSD: src/include/getopt.h,v 1.6 2004/02/24 08:09:20 ache Exp $ */
00003 
00004 /*-
00005  * Copyright (c) 2000 The NetBSD Foundation, Inc.
00006  * All rights reserved.
00007  *
00008  * This code is derived from software contributed to The NetBSD Foundation
00009  * by Dieter Baron and Thomas Klausner.
00010  *
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions
00013  * are met:
00014  * 1. Redistributions of source code must retain the above copyright
00015  *    notice, this list of conditions and the following disclaimer.
00016  * 2. Redistributions in binary form must reproduce the above copyright
00017  *    notice, this list of conditions and the following disclaimer in the
00018  *    documentation and/or other materials provided with the distribution.
00019  * 3. All advertising materials mentioning features or use of this software
00020  *    must display the following acknowledgement:
00021  *        This product includes software developed by the NetBSD
00022  *        Foundation, Inc. and its contributors.
00023  * 4. Neither the name of The NetBSD Foundation nor the names of its
00024  *    contributors may be used to endorse or promote products derived
00025  *    from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
00028  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00029  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
00031  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038 * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
00039  */
00040 
00041 #ifndef _GETOPT_H_
00042 #define _GETOPT_H_
00043 
00044 #include <sys/cdefs.h>
00045 
00046 /*
00047  * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
00048  * getopt() is declared here too for GNU programs.
00049  */
00050 #define no_argument        0
00051 #define required_argument  1
00052 #define optional_argument  2
00053 
00054 struct option {
00055         /* name of long option */
00056         const char *name;
00057         /*
00058          * one of no_argument, required_argument, and optional_argument:
00059          * whether option takes an argument
00060          */
00061         int has_arg;
00062         /* if not NULL, set *flag to val when option found */
00063         int *flag;
00064         /* if flag not NULL, value to set *flag to; else return value */
00065         int val;
00066 };
00067 
00068 __BEGIN_DECLS
00069 IMPORT_C int    getopt_long(int, char * const *, const char *,
00070         const struct option *, int *);
00071 #ifndef _GETOPT_DECLARED
00072 #define _GETOPT_DECLARED
00073 IMPORT_C int     getopt(int, char * const [], const char *);
00074 
00075 #ifndef __SYMBIAN32__
00076 extern char *optarg;                    /* getopt(3) external variables */
00077 extern int optind, opterr, optopt;
00078 #else
00079 IMPORT_C int *__optopt(void);
00080 IMPORT_C int *__opterr(void);
00081 IMPORT_C int *__optind(void);
00082 IMPORT_C char **__optarg(void);
00083 #define optopt    (*__optopt())
00084 #define opterr    (*__opterr())
00085 #define optind    (*__optind())
00086 #define optarg    (*__optarg())
00087 #endif /* __SYMBIAN32__ */
00088 
00089 #endif /* _GETOPT_DECLARED */
00090 #ifndef _OPTRESET_DECLARED
00091 #define _OPTRESET_DECLARED
00092 
00093 #ifndef __SYMBIAN32__
00094 extern int optreset;                    /* getopt(3) external variable */
00095 #else
00096 IMPORT_C int *__optreset(void);
00097 #define optreset  (*__optreset())
00098 #endif /* __SYMBIAN32__ */
00099 
00100 #endif /*_OPTRESET_DECLARED */
00101 __END_DECLS
00102  
00103 #endif /* !_GETOPT_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top