sl@0: /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ sl@0: /* $FreeBSD: src/include/getopt.h,v 1.6 2004/02/24 08:09:20 ache Exp $ */ sl@0: sl@0: /*- sl@0: * Copyright (c) 2000 The NetBSD Foundation, Inc. sl@0: * All rights reserved. sl@0: * sl@0: * This code is derived from software contributed to The NetBSD Foundation sl@0: * by Dieter Baron and Thomas Klausner. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of The NetBSD Foundation nor the names of its sl@0: * contributors may be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS sl@0: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED sl@0: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS sl@0: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR sl@0: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF sl@0: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS sl@0: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN sl@0: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE sl@0: * POSSIBILITY OF SUCH DAMAGE. sl@0: * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: */ sl@0: sl@0: #ifndef _GETOPT_H_ sl@0: #define _GETOPT_H_ sl@0: sl@0: #include sl@0: sl@0: /* sl@0: * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension. sl@0: * getopt() is declared here too for GNU programs. sl@0: */ sl@0: #define no_argument 0 sl@0: #define required_argument 1 sl@0: #define optional_argument 2 sl@0: sl@0: struct option { sl@0: /* name of long option */ sl@0: const char *name; sl@0: /* sl@0: * one of no_argument, required_argument, and optional_argument: sl@0: * whether option takes an argument sl@0: */ sl@0: int has_arg; sl@0: /* if not NULL, set *flag to val when option found */ sl@0: int *flag; sl@0: /* if flag not NULL, value to set *flag to; else return value */ sl@0: int val; sl@0: }; sl@0: sl@0: __BEGIN_DECLS sl@0: IMPORT_C int getopt_long(int, char * const *, const char *, sl@0: const struct option *, int *); sl@0: #ifndef _GETOPT_DECLARED sl@0: #define _GETOPT_DECLARED sl@0: IMPORT_C int getopt(int, char * const [], const char *); sl@0: sl@0: #ifndef __SYMBIAN32__ sl@0: extern char *optarg; /* getopt(3) external variables */ sl@0: extern int optind, opterr, optopt; sl@0: #else sl@0: IMPORT_C int *__optopt(void); sl@0: IMPORT_C int *__opterr(void); sl@0: IMPORT_C int *__optind(void); sl@0: IMPORT_C char **__optarg(void); sl@0: #define optopt (*__optopt()) sl@0: #define opterr (*__opterr()) sl@0: #define optind (*__optind()) sl@0: #define optarg (*__optarg()) sl@0: #endif /* __SYMBIAN32__ */ sl@0: sl@0: #endif /* _GETOPT_DECLARED */ sl@0: #ifndef _OPTRESET_DECLARED sl@0: #define _OPTRESET_DECLARED sl@0: sl@0: #ifndef __SYMBIAN32__ sl@0: extern int optreset; /* getopt(3) external variable */ sl@0: #else sl@0: IMPORT_C int *__optreset(void); sl@0: #define optreset (*__optreset()) sl@0: #endif /* __SYMBIAN32__ */ sl@0: sl@0: #endif /*_OPTRESET_DECLARED */ sl@0: __END_DECLS sl@0: sl@0: #endif /* !_GETOPT_H_ */