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