coan
6.0.1
A C/C++ Configuration Analyzer
|
Go to the source code of this file.
Functions | |
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. More... | |
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. More... | |
int | getopt_long (int argc, char *argv[], const char *optstr, const struct option *longopts, int *longind) |
Parse commandline options. More... | |
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 . More... | |
Variables | |
int | optind |
Index of option parsed by getopt_long() | |
int | optopt |
Unrecogised short option parsed by getopt_long() | |
char * | optarg |
Argument to an option parsed by getopt_long() | |
This file implements the get_options
API
Definition in file get_options.cpp.
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.
argc | The number of commandline arguments. |
argv | The array of commandline arguments. |
commands | An array of valid command options. |
argc
< 2 return nullptr
. Else if argv[1]
matches the name
field in any of the command options listed in commands
, return the address of that command option, else return nullptr
. Definition at line 52 of file get_options.cpp.
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
.
longopts | The array of option info to be searched, terminated by a struct option in which the name field is nullptr . |
opt | The option code to be sought. |
opt
, if found, else nullptr
. Definition at line 249 of file get_options.cpp.
int getopt_long | ( | int | argc, |
char * | argv[], | ||
const char * | optstr, | ||
struct option const * | longopts, | ||
int * | longind | ||
) |
Parse commandline options.
We need the standard getopt_long()
function, but the host implementation cannot be relied on to be re-entrant. Therefore we roll our own re-entrant version. The interface is like that of its standard namesake.
argc | The number of commandline arguments |
argv | Array of pointers to the commandline arguments. |
optstr | A string containing the legitimate option characters. |
longopts | A pointer to the first element of an array of struct option . |
longind | A pointer at which is stored on return the index of any long option parsed. |
Definition at line 97 of file get_options.cpp.
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.
opt_excluder | To be determined if this option excludes another. |
opt_excluded | To be determined if this option is excluded by opt_excluder . |
exclusions | Addresses an array of exclusions lists,terminated by an exclusion list in which the excluder field is 0, in which a list belonging to opt_excluder will be sought. |
indexed | If true then the function may assume that opt_excluder is an index to its exclusion list in exclusions . |
exclusions
is found to contain an exclusion list whose excluder
field is opt_excluder
and whose excluded
field is an array containing opt_excluded
. Otherwise true. Definition at line 67 of file get_options.cpp.