Navit SVN

/work/compile/navit/src/navit/support/libc/getopt.h

00001 #ifndef __GETOPT_H__
00002 /* 
00003  * getopt.h
00004  *
00005  * $Id: getopt.h,v 1.4 2009/01/04 17:35:36 keithmarshall Exp $
00006  *
00007  * Defines constants and function prototypes required to implement
00008  * the `getopt', `getopt_long' and `getopt_long_only' APIs.
00009  *
00010  * This file is part of the MinGW32 package set.
00011  *
00012  * Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
00013  *
00014  *
00015  * THIS SOFTWARE IS NOT COPYRIGHTED
00016  *
00017  * This source code is offered for use in the public domain. You may
00018  * use, modify or distribute it freely.
00019  *
00020  * This code is distributed in the hope that it will be useful but
00021  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00022  * DISCLAIMED. This includes but is not limited to warranties of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00024  *
00025  * $Revision: 1.4 $
00026  * $Author: keithmarshall $
00027  * $Date: 2009/01/04 17:35:36 $
00028  *
00029  */
00030 #define __GETOPT_H__
00031 
00032 /* All the headers include this file. */
00033 #include <_mingw.h>
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 extern int optind;              /* index of first non-option in argv      */
00040 extern int optopt;              /* single option character, as parsed     */
00041 extern int opterr;              /* flag to enable built-in diagnostics... */
00042                                 /* (user may set to zero, to suppress)    */
00043 
00044 extern char *optarg;            /* pointer to argument of current option  */
00045 
00046 extern int getopt( int, char * const [], const char * );
00047 
00048 #ifdef _BSD_SOURCE
00049 /*
00050  * BSD adds the non-standard `optreset' feature, for reinitialisation
00051  * of `getopt' parsing.  We support this feature, for applications which
00052  * proclaim their BSD heritage, before including this header; however,
00053  * to maintain portability, developers are advised to avoid it.
00054  */
00055 # define optreset  __mingw_optreset
00056 
00057 extern int optreset;
00058 #endif
00059 #ifdef __cplusplus
00060 }
00061 #endif
00062 /*
00063  * POSIX requires the `getopt' API to be specified in `unistd.h';
00064  * thus, `unistd.h' includes this header.  However, we do not want
00065  * to expose the `getopt_long' or `getopt_long_only' APIs, when
00066  * included in this manner.  Thus, close the standard __GETOPT_H__
00067  * declarations block, and open an additional __GETOPT_LONG_H__
00068  * specific block, only when *not* __UNISTD_H_SOURCED__, in which
00069  * to declare the extended API.
00070  */
00071 #endif /* !defined(__GETOPT_H__) */
00072 #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
00073 #define __GETOPT_LONG_H__
00074 
00075 #ifdef __cplusplus
00076 extern "C" {
00077 #endif
00078 
00079 struct option           /* specification for a long form option...      */
00080 {
00081   const char *name;             /* option name, without leading hyphens */
00082   int         has_arg;          /* does it take an argument?            */
00083   int        *flag;             /* where to save its status, or NULL    */
00084   int         val;              /* its associated status value          */
00085 };
00086 
00087 enum                    /* permitted values for its `has_arg' field...  */
00088 {
00089   no_argument = 0,              /* option never takes an argument       */
00090   required_argument,            /* option always requires an argument   */
00091   optional_argument             /* option may take an argument          */
00092 };
00093 
00094 extern int getopt_long( int, char * const [], const char *, const struct option *, int * );
00095 extern int getopt_long_only( int, char * const [], const char *, const struct option *, int * );
00096 /*
00097  * Previous MinGW implementation had...
00098  */
00099 #ifndef HAVE_DECL_GETOPT
00100 /*
00101  * ...for the long form API only; keep this for compatibility.
00102  */
00103 # define HAVE_DECL_GETOPT       1
00104 #endif
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
00111 /* $RCSfile: getopt.h,v $Revision: 1.4 $: end of file */