Linux Standard Base Core Specification 3.1 | ||
---|---|---|
<<< Previous | Next >>> |
getopt_long() works like getopt() except that it also accepts long options, started out by two dashes. Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option. A long option may take a parameter, of the form --arg=param or --arg param.
longopts is a pointer to the first element of an array of struct option declared in getopt.h as:
struct option { const char *name; int has_arg; int *flag; int val; }; |
The fields in this structure have the following meaning:
getopt_long() returns the option character if a short option was found successfully, or ":" if there was a missing parameter for one of the options, or "?" for an unknown option character, or -1 for the end of the option list.
For a long option,
getopt_long() returns val
if flag
is NULL, and 0
otherwise. Error and -1 returns are the
same as for getopt(), plus
"?" for an ambiguous match or an
extraneous parameter.
<<< Previous | Home | Next >>> |
getopt | Up | getopt_long_only |