Next: libefi-mm, Previous: libefi-string, Up: libefi
The `efi' library contains functionality for parsing options.
The parsing framework is modeled after argp
from the gnu C
library. The application defines a list of valid options, and pass
them together with a parse hook to the efi_argp_parse
method.
The hook will get invoked during the parsing with information about
what option was just parsed. Definitions and prototypes is available
in gnu/efi/util/argp.h.
The options is defined as a NULL terminated array of efi_argp_option_t
structures. The efi_argp_option_t
structure has the following
members:
Long argument name of the option, if any. Long arguments are argumnets that start with `--'. For example --output.
Short argument name of the option, if any. Short argument are arguments that start with `-'. For example -o.
Option flags. The only flag currently available is
EFI_ARGP_ARG_OPTIONAL
which defines that the option takes an optional argument.
Name of the argument that the option takes. Should be in uppercase.
FIXME: If neither longarg nor shortarg is specified in the option is treated as an mandatory argument to the program. If no option is defined for the program argument, the hook will be invoked with opt as NULL but a valid arg argument.
FIXME: When all options has been parsed the parser will invoke the hook with opt and arg set to NULL to signal that all options has been parsed.
The signature of the hook:
Parse hook invoked from the option parser. DATA is a user defined pointer that was provided to efi_argp_parse. opt is the option that was pased, and arg is an optional argument to the option. The hook should return
EFI_SUCCESS
if it could handle the option.
Caution: The option parser uses the first argument passed to
efi_argp_parse
as the program name.
Parse options and invoke hook hook with the parsed option. options is a list of options that should be parsed. argc is the number of arguments passed to the program. argv is an array of all arguments. data is a user defined pointer that will be passed to the hook.