coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
get_options.h
Go to the documentation of this file.
1 #ifndef GET_OPTIONS_H
2 #define GET_OPTIONS_H
3 #pragma once
4 /***************************************************************************
5  * Copyright (C) 2004 - 2006 Symbian Software Ltd. *
6  * All rights reserved. *
7  * Copyright (C) 2007-2013 Mike Kinghan, imk@burroingroingjoing.com *
8  * All rights reserved. *
9  * *
10  * Contributed originally by Mike Kinghan, imk@burroingroingjoing.com *
11  * *
12  * Redistribution and use in source and binary forms, with or without *
13  * modification, are permitted provided that the following conditions *
14  * are met: *
15  * *
16  * Redistributions of source code must retain the above copyright *
17  * notice, this list of conditions and the following disclaimer. *
18  * *
19  * Redistributions in binary form must reproduce the above copyright *
20  * notice, this list of conditions and the following disclaimer in the *
21  * documentation and/or other materials provided with the distribution. *
22  * *
23  * Neither the name of Symbian Software Ltd. nor the names of its *
24  * contributors may be used to endorse or promote products derived from *
25  * this software without specific prior written permission. *
26  * *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
30  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
31  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
33  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
34  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
35  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
36  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
37  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
38  * DAMAGE. *
39  * *
40  **************************************************************************/
41 
42 #include "platform.h"
43 
49 extern int optind;
51 extern int optopt;
53 extern char *optarg;
55 
57 struct option {
59  const char *name;
66  int has_arg;
67 
76  int *flag;
82  int val;
83 };
84 
86 enum {
90 };
91 
92 
94 struct cmd_option {
96  const char *name;
98  int cmd_code;
99 };
100 
106  int excluder;
108  int const * excluded;
109 };
110 
119 extern cmd_option const *
120 get_command_option(int argc, char *argv[], cmd_option const * commands);
121 
139 extern bool
140 opts_are_compatible( int opt_excluder, int opt_excluded,
141  struct exclusion_list const *exclusions, bool indexed);
142 
143 #ifdef GNUWIN
144 /* Avoid linkage clash with mingw function */
145 #define getopt_long getoptions_long
146 #endif
147 
163 extern int
164 getopt_long(int argc, char * argv[], const char *optstr,
165  struct option const *longopts, int *longind);
166 
176 extern const char *
177 get_long_opt_name(struct option const * longopts, int opt);
178 
179 #endif /* EOF*/
The option cannot have an argument.
Definition: get_options.h:87
int val
Value to be returned or stored by getopt_long().
Definition: get_options.h:82
const char * name
The name of the option.
Definition: get_options.h:96
Info structure for an option for getopt_long().
Definition: get_options.h:57
int getopt_long(int argc, char *argv[], const char *optstr, struct option const *longopts, int *longind)
Parse commandline options.
Definition: get_options.cpp:97
bool opts_are_compatible(int opt_excluder, int opt_excluded, struct exclusion_list const *exclusions, bool indexed)
Say whether options are compatible with respect to specified incompatibilities.
Definition: get_options.cpp:67
const char * name
The name of the option.
Definition: get_options.h:59
int const * excluded
This 0-terminated list of option codes is excluded by excluder.
Definition: get_options.h:108
int cmd_code
Value to be returned if the command is matched.
Definition: get_options.h:98
The option must have an argument.
Definition: get_options.h:88
char * optarg
Argument to an option parsed by getopt_long()
Definition: get_options.cpp:49
cmd_option const * get_command_option(int argc, char *argv[], cmd_option const *commands)
Look for a command option at the start of commandline arguments.
Definition: get_options.cpp:52
int * flag
Mode flag.
Definition: get_options.h:76
int optopt
Unrecogised short option parsed by getopt_long()
Definition: get_options.cpp:48
Info structure for a command option for get_command()
Definition: get_options.h:94
int optind
Index of option parsed by getopt_long()
Definition: get_options.cpp:47
const char * get_long_opt_name(struct option const *longopts, int opt)
Look up the long name of the an option in an array of struct option.
int has_arg
Can the option take an argument? One of:
Definition: get_options.h:66
int excluder
This option code excludes the others.
Definition: get_options.h:106
Structure representing a set of options that are excluded by another option.
Definition: get_options.h:104
The option may or may not have an argument.
Definition: get_options.h:89