Go to the source code of this file.
|
int | fe_getopt (int argc, char *const *argv, const char *shortopts) |
|
int | fe_getopt_long (int argc, char *const *argv, const char *shortopts, const struct fe_option *longopts, int *longind) |
|
int | fe_getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct fe_option *longopts, int *longind) |
|
int | _fe_getopt_internal (int argc, char *const *argv, const char *shortopts, const struct fe_option *longopts, int *longind, int long_only) |
|
◆ fe_option
Definition at line 78 of file fegetopt.h.
Data Fields |
const char * |
arg_name |
|
int |
has_arg |
|
const char * |
help |
|
char * |
name |
|
int |
set |
|
feOptType |
type |
|
int |
val |
|
void * |
value |
|
◆ no_argument
◆ optional_argument
#define optional_argument 2 |
◆ required_argument
#define required_argument 1 |
◆ feOptType
Enumerator |
---|
feOptUntyped | |
feOptBool | |
feOptInt | |
feOptString | |
Definition at line 77 of file fegetopt.h.
◆ _fe_getopt_internal()
int _fe_getopt_internal |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
shortopts, |
|
|
const struct fe_option * |
longopts, |
|
|
int * |
longind, |
|
|
int |
long_only |
|
) |
| |
Definition at line 327 of file fegetopt.c.
352 if (optstring[0] ==
'-')
357 else if (optstring[0] ==
'+')
449 && (argv[
fe_optind][1] ==
'-' || long_only))
462 while (*
s && *
s !=
'=')
466 for (
p = longopts, option_index = 0;
p->name;
474 indfound = option_index;
478 else if (pfound ==
NULL)
482 indfound = option_index;
492 fprintf (stderr,
"%s: option `%s' is ambiguous\n",
501 option_index = indfound;
516 "%s: option `--%s' doesn't allow an argument\n",
517 argv[0], pfound->
name);
521 "%s: option `%c%s' doesn't allow an argument\n",
535 fprintf (stderr,
"%s: option `%s' requires an argument\n",
538 return optstring[0] ==
':' ?
':' :
BAD_OPTION;
543 *longind = option_index;
550 if (!long_only || argv[
fe_optind][1] ==
'-'
560 fprintf (stderr,
"%s: unrecognized option `--%s'\n",
564 fprintf (stderr,
"%s: unrecognized option `%c%s'\n",
577 const char *temp =
my_index (optstring, c);
583 if (temp ==
NULL || c ==
':')
588 if (c < 040 || c >= 0177)
589 fprintf (stderr,
"%s: unrecognized option, character code 0%o\n",
592 fprintf (stderr,
"%s: unrecognized option `-%c'\n", argv[0], c);
595 fprintf (stderr,
"%s: illegal option -- %c\n", argv[0], c);
630 fprintf (stderr,
"%s: option `-%c' requires an argument\n",
634 fprintf (stderr,
"%s: option requires an argument -- %c\n",
639 if (optstring[0] ==
':')
const CanonicalForm int s
static void exchange(char **argv)
static size_t my_strlen(const char *str)
static const char * my_index(const char *str, int chr)
◆ fe_getopt()
int fe_getopt |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
shortopts |
|
) |
| |
Definition at line 655 of file fegetopt.c.
int _fe_getopt_internal(int argc, char *const *argv, const char *optstring, const struct fe_option *longopts, int *longind, int long_only)
◆ fe_getopt_long()
int fe_getopt_long |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
shortopts, |
|
|
const struct fe_option * |
longopts, |
|
|
int * |
longind |
|
) |
| |
◆ fe_getopt_long_only()
int fe_getopt_long_only |
( |
int |
argc, |
|
|
char *const * |
argv, |
|
|
const char * |
shortopts, |
|
|
const struct fe_option * |
longopts, |
|
|
int * |
longind |
|
) |
| |
◆ fe_optarg
◆ fe_opterr
◆ fe_optind
◆ fe_optopt