57 for ( ; command->
name; ++command) {
58 if (!strcmp(argv[1],command->
name)) {
74 which = exclusions + opt_excluder;
78 if (which->
excluder == opt_excluder) {
87 if (opt_excluded == *excluded) {
98 const struct option *longopts,
int *longind)
122 char const *where = strchr(optstr,*opt);
127 if (where[1] !=
':') {
134 }
else if (where[2] !=
':') {
163 char *eq = strchr(++opt,
'=');
168 optlen = strlen(opt);
171 for (i = 0; longopts[i].
name !=
nullptr; ++i) {
172 if (!strncmp(opt,longopts[i].
name,optlen)) {
180 if (longind !=
nullptr) {
186 switch(longopts[match].has_arg) {
217 if (longopts[match].flag !=
nullptr) {
218 *(longopts[match].
flag) = longopts[i].val;
221 return longopts[match].
val;
229 for (i =
optind; done && i < argc; ++i) {
231 done = *argv[i] !=
'-';
238 char *temp = argv[
optind];
240 (argc -
optind - 1) *
sizeof(
char *));
241 argv[argc - 1] = temp;
243 return getopt_long(argc,argv,optstr,longopts,longind);
251 struct option const * longopt = longopts;
252 for ( ; longopt->
name; ++longopt) {
253 if (longopt->
val == opt) {
254 return longopt->
name;
The option cannot have an argument.
int val
Value to be returned or stored by getopt_long().
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 optind
Index of option parsed by getopt_long()
int getopt_long(int argc, char *argv[], const char *optstr, const struct option *longopts, int *longind)
Parse commandline options.
const char * name
The name of the option.
Info structure for an option for getopt_long().
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.
const char * name
The name of the option.
int const * excluded
This 0-terminated list of option codes is excluded by excluder.
chew_mode::name const name
An exemplar chew_mode::name
int optopt
Unrecogised short option parsed by getopt_long()
The option must have an argument.
Info structure for a command option for get_command()
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.
int excluder
This option code excludes the others.
Structure representing a set of options that are excluded by another option.
char * optarg
Argument to an option parsed by getopt_long()
The option may or may not have an argument.