coan 4.2.4
|
00001 #ifndef GET_OPTIONS_H 00002 #define GET_OPTIONS_H 00003 /*************************************************************************** 00004 * Copyright (C) 2004 - 2006 Symbian Software Ltd. * 00005 * All rights reserved. * 00006 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00007 * All rights reserved. * 00008 * * 00009 * Contributed originally by Mike Kinghan, imk@strudl.org * 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 * * 00015 * Redistributions of source code must retain the above copyright * 00016 * notice, this list of conditions and the following disclaimer. * 00017 * * 00018 * Redistributions in binary form must reproduce the above copyright * 00019 * notice, this list of conditions and the following disclaimer in the * 00020 * documentation and/or other materials provided with the distribution. * 00021 * * 00022 * Neither the name of Symbian Software Ltd. nor the names of its * 00023 * contributors may be used to endorse or promote products derived from * 00024 * this software without specific prior written permission. * 00025 * * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00027 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00028 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00029 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00030 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00031 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00032 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00033 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00034 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00035 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00036 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00037 * DAMAGE. * 00038 * * 00039 **************************************************************************/ 00040 00041 #include "platform.h" 00042 #include "bool.h" 00043 00051 00052 extern int optind; 00054 extern int optopt; 00056 extern char *optarg; 00060 struct option { 00062 const char *name; 00068 int has_arg; 00075 int *flag; 00079 int val; 00080 }; 00081 00083 enum { 00084 no_argument, 00085 required_argument, 00086 optional_argument 00087 }; 00088 00089 00091 typedef struct cmd_option { 00093 const char *name; 00095 int cmd_code; 00097 int cmd_mask; 00098 } cmd_option_t; 00099 00103 struct exclusion_list { 00104 int excluder; 00105 int const * excluded; 00107 }; 00108 00117 extern cmd_option_t const * 00118 get_command_option(int argc, char *argv[], cmd_option_t const * commands); 00119 00137 extern bool 00138 opts_are_compatible( int opt_excluder, int opt_excluded, 00139 struct exclusion_list const *exclusions, bool indexed); 00140 00145 #ifdef GNUWIN 00146 /* Avoid linkage clash with mingw function */ 00147 #define getopt_long getoptions_long 00148 #endif 00149 extern int 00150 getopt_long(int argc, char * argv[], const char *optstr, 00151 struct option const *longopts, int *longind); 00152 00161 extern const char * 00162 get_long_opt_name(struct option const * longopts, int opt); 00163 00166 #endif /* EOF*/ 00167