epoc32/include/stdapis/getopt.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/stdapis/getopt.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/getopt.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,99 @@
     1.4 -getopt.h
     1.5 +/*	$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $	*/
     1.6 +/*	$FreeBSD: src/include/getopt.h,v 1.6 2004/02/24 08:09:20 ache Exp $ */
     1.7 +
     1.8 +/*-
     1.9 + * Copyright (c) 2000 The NetBSD Foundation, Inc.
    1.10 + * All rights reserved.
    1.11 + *
    1.12 + * This code is derived from software contributed to The NetBSD Foundation
    1.13 + * by Dieter Baron and Thomas Klausner.
    1.14 + *
    1.15 + * Redistribution and use in source and binary forms, with or without
    1.16 + * modification, are permitted provided that the following conditions
    1.17 + * are met:
    1.18 + * 1. Redistributions of source code must retain the above copyright
    1.19 + *    notice, this list of conditions and the following disclaimer.
    1.20 + * 2. Redistributions in binary form must reproduce the above copyright
    1.21 + *    notice, this list of conditions and the following disclaimer in the
    1.22 + *    documentation and/or other materials provided with the distribution.
    1.23 + * 4. Neither the name of The NetBSD Foundation nor the names of its
    1.24 + *    contributors may be used to endorse or promote products derived
    1.25 + *    from this software without specific prior written permission.
    1.26 + *
    1.27 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
    1.28 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    1.29 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    1.30 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
    1.31 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.32 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.33 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.34 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.35 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.36 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.37 + * POSSIBILITY OF SUCH DAMAGE.
    1.38 +* © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
    1.39 + */
    1.40 +
    1.41 +#ifndef _GETOPT_H_
    1.42 +#define _GETOPT_H_
    1.43 +
    1.44 +#include <sys/cdefs.h>
    1.45 +
    1.46 +/*
    1.47 + * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
    1.48 + * getopt() is declared here too for GNU programs.
    1.49 + */
    1.50 +#define no_argument        0
    1.51 +#define required_argument  1
    1.52 +#define optional_argument  2
    1.53 +
    1.54 +struct option {
    1.55 +	/* name of long option */
    1.56 +	const char *name;
    1.57 +	/*
    1.58 +	 * one of no_argument, required_argument, and optional_argument:
    1.59 +	 * whether option takes an argument
    1.60 +	 */
    1.61 +	int has_arg;
    1.62 +	/* if not NULL, set *flag to val when option found */
    1.63 +	int *flag;
    1.64 +	/* if flag not NULL, value to set *flag to; else return value */
    1.65 +	int val;
    1.66 +};
    1.67 +
    1.68 +__BEGIN_DECLS
    1.69 +IMPORT_C int	getopt_long(int, char * const *, const char *,
    1.70 +	const struct option *, int *);
    1.71 +#ifndef _GETOPT_DECLARED
    1.72 +#define	_GETOPT_DECLARED
    1.73 +IMPORT_C int	 getopt(int, char * const [], const char *);
    1.74 +
    1.75 +#ifndef __SYMBIAN32__
    1.76 +extern char *optarg;			/* getopt(3) external variables */
    1.77 +extern int optind, opterr, optopt;
    1.78 +#else
    1.79 +IMPORT_C int *__optopt(void);
    1.80 +IMPORT_C int *__opterr(void);
    1.81 +IMPORT_C int *__optind(void);
    1.82 +IMPORT_C char **__optarg(void);
    1.83 +#define optopt	  (*__optopt())
    1.84 +#define opterr	  (*__opterr())
    1.85 +#define optind	  (*__optind())
    1.86 +#define optarg	  (*__optarg())
    1.87 +#endif /* __SYMBIAN32__ */
    1.88 +
    1.89 +#endif /* _GETOPT_DECLARED */
    1.90 +#ifndef _OPTRESET_DECLARED
    1.91 +#define	_OPTRESET_DECLARED
    1.92 +
    1.93 +#ifndef __SYMBIAN32__
    1.94 +extern int optreset;			/* getopt(3) external variable */
    1.95 +#else
    1.96 +IMPORT_C int *__optreset(void);
    1.97 +#define optreset  (*__optreset())
    1.98 +#endif /* __SYMBIAN32__ */
    1.99 +
   1.100 +#endif /*_OPTRESET_DECLARED */
   1.101 +__END_DECLS
   1.102 + 
   1.103 +#endif /* !_GETOPT_H_ */