|
iPXE
|
Command line option parsing. More...
Go to the source code of this file.
Data Structures | |
| struct | option_descriptor |
| A command-line option descriptor. More... | |
| struct | command_descriptor |
| A command descriptor. More... | |
| struct | named_setting |
| A parsed named setting. More... | |
| struct | uuid_option |
| A UUID command-line option. More... | |
Macros | |
| #define | OPTION_PARSER(_struct, _field, _parse) |
| Construct option parser. More... | |
| #define | OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse) |
| Construct option descriptor. More... | |
| #define | MAX_ARGUMENTS 0xff |
| No maximum number of arguments. More... | |
| #define | COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage) |
| Construct command descriptor. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| int | parse_string (char *text, char **value) |
| Parse string value. More... | |
| int | parse_integer (char *text, unsigned int *value) |
| Parse integer value. More... | |
| int | parse_timeout (char *text, unsigned long *value) |
| Parse timeout value (in ms) More... | |
| int | parse_uuid (char *text, struct uuid_option *uuid) |
| Parse UUID. More... | |
| int | parse_netdev (char *text, struct net_device **netdev) |
| Parse network device name. More... | |
| int | parse_netdev_configurator (char *text, struct net_device_configurator **configurator) |
| Parse network device configurator name. More... | |
| int | parse_dynui (char *text, struct dynamic_ui **dynui) |
| Parse dynamic user interface name. More... | |
| int | parse_flag (char *text __unused, int *flag) |
| Parse flag. More... | |
| int | parse_key (char *text, unsigned int *key) |
| Parse key. More... | |
| int | parse_settings (char *text, struct settings **settings) |
| Parse settings block name. More... | |
| int | parse_setting (char *text, struct named_setting *setting, get_child_settings_t get_child) |
| Parse setting name. More... | |
| int | parse_existing_setting (char *text, struct named_setting *setting) |
| Parse existing setting name. More... | |
| int | parse_autovivified_setting (char *text, struct named_setting *setting) |
| Parse and autovivify setting name. More... | |
| int | parse_parameters (char *text, struct parameters **params) |
| Parse request parameter list name. More... | |
| void | print_usage (struct command_descriptor *cmd, char **argv) |
| Print command usage message. More... | |
| int | reparse_options (int argc, char **argv, struct command_descriptor *cmd, void *opts) |
| Reparse command-line options. More... | |
| int | parse_options (int argc, char **argv, struct command_descriptor *cmd, void *opts) |
| Parse command-line options. More... | |
Command line option parsing.
Definition in file parseopt.h.
| #define OPTION_PARSER | ( | _struct, | |
| _field, | |||
| _parse | |||
| ) |
Construct option parser.
| _struct | Options structure type |
| _field | Field within options structure |
| _parse | Field type-specific option parser |
| _parse | Generic option parser |
Definition at line 49 of file parseopt.h.
| #define OPTION_DESC | ( | _longopt, | |
| _shortopt, | |||
| _has_arg, | |||
| _struct, | |||
| _field, | |||
| _parse | |||
| ) |
Construct option descriptor.
| _longopt | Long option name, if any |
| _shortopt | Short option name, if any |
| _has_arg | Argument requirement |
| _struct | Options structure type |
| _field | Field within options structure |
| _parse | Field type-specific option parser |
| _option | Option descriptor |
Definition at line 67 of file parseopt.h.
| #define MAX_ARGUMENTS 0xff |
No maximum number of arguments.
Definition at line 97 of file parseopt.h.
| #define COMMAND_DESC | ( | _struct, | |
| _options, | |||
| _min_args, | |||
| _max_args, | |||
| _usage | |||
| ) |
Construct command descriptor.
| _struct | Options structure type |
| _options | Option descriptor array |
| _check_args | Remaining argument checker |
| _usage | Command usage |
| _command | Command descriptor |
Definition at line 108 of file parseopt.h.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| int parse_string | ( | char * | text, |
| char ** | value | ||
| ) |
Parse string value.
| text | Text |
| value | String value |
| rc | Return status code |
Definition at line 73 of file parseopt.c.
| int parse_integer | ( | char * | text, |
| unsigned int * | value | ||
| ) |
Parse integer value.
| text | Text |
| value | Integer value |
| rc | Return status code |
Definition at line 91 of file parseopt.c.
References assert(), EINVAL_INTEGER, NULL, printf(), strtoul(), and value.
Referenced by colour_exec(), cpair_exec(), cpuid_exec(), exit_exec(), imgmem_exec(), inc_exec(), parse_key(), parse_timeout(), pxebs_exec(), and sleep_exec().
| int parse_timeout | ( | char * | text, |
| unsigned long * | value | ||
| ) |
Parse timeout value (in ms)
| text | Text |
| value | Integer value |
| rc | Return status code |
Definition at line 114 of file parseopt.c.
References parse_integer(), rc, TICKS_PER_MS, and value.
| int parse_uuid | ( | char * | text, |
| struct uuid_option * | uuid | ||
| ) |
Parse UUID.
| text | Text |
| uuid | UUID value |
| rc | Return status code |
Definition at line 135 of file parseopt.c.
References assert(), NULL, printf(), rc, and uuid_aton().
| int parse_netdev | ( | char * | text, |
| struct net_device ** | netdev | ||
| ) |
Parse network device name.
| text | Text |
| netdev | Network device |
| rc | Return status code |
Definition at line 158 of file parseopt.c.
References assert(), ENODEV, find_netdev(), netdev, NULL, and printf().
Referenced by ifcommon_exec(), lotest_exec(), pxebs_exec(), vcreate_exec(), and vdestroy_exec().
| int parse_netdev_configurator | ( | char * | text, |
| struct net_device_configurator ** | configurator | ||
| ) |
Parse network device configurator name.
| text | Text |
| configurator | Network device configurator |
| rc | Return status code |
Definition at line 180 of file parseopt.c.
References assert(), ENOTSUP, find_netdev_configurator(), NULL, and printf().
| int parse_dynui | ( | char * | text, |
| struct dynamic_ui ** | dynui | ||
| ) |
Parse dynamic user interface name.
| text | Text |
| dynui | Dynamic user interface |
| rc | Return status code |
Definition at line 203 of file parseopt.c.
References ENOENT, find_dynui(), and printf().
Referenced by choose_exec(), item_exec(), and present_exec().
| int parse_flag | ( | char *text | __unused, |
| int * | flag | ||
| ) |
Parse flag.
| text | Text (ignored) |
| flag | Flag to set |
| rc | Return status code |
Definition at line 226 of file parseopt.c.
References flag.
| int parse_key | ( | char * | text, |
| unsigned int * | key | ||
| ) |
Parse key.
| text | Text |
| key | Key |
| rc | Return status code |
Definition at line 241 of file parseopt.c.
References isascii(), key, KEY_MIN, parse_integer(), and rc.
| int parse_settings | ( | char * | text, |
| struct settings ** | value | ||
| ) |
Parse settings block name.
| text | Text |
| value | Integer value |
| rc | Return status code |
Definition at line 271 of file parseopt.c.
References assert(), EINVAL, find_settings(), NULL, printf(), and value.
Referenced by config_exec().
| int parse_setting | ( | char * | text, |
| struct named_setting * | setting, | ||
| get_child_settings_t | get_child | ||
| ) |
Parse setting name.
| text | Text |
| setting | Named setting to fill in |
| get_child | Function to find or create child settings block |
| rc | Return status code |
Note that this function modifies the original text.
Definition at line 296 of file parseopt.c.
References assert(), NULL, parse_setting_name(), printf(), and rc.
Referenced by parse_autovivified_setting(), and parse_existing_setting().
| int parse_existing_setting | ( | char * | text, |
| struct named_setting * | setting | ||
| ) |
Parse existing setting name.
| text | Text |
| setting | Named setting to fill in |
| rc | Return status code |
Note that this function modifies the original text.
Definition at line 322 of file parseopt.c.
References find_child_settings(), and parse_setting().
Referenced by inc_exec(), and show_exec().
| int parse_autovivified_setting | ( | char * | text, |
| struct named_setting * | setting | ||
| ) |
Parse and autovivify setting name.
| text | Text |
| setting | Named setting to fill in |
| rc | Return status code |
Note that this function modifies the original text.
Definition at line 336 of file parseopt.c.
References autovivify_child_settings(), and parse_setting().
Referenced by choose_exec(), pciscan_exec(), set_core_exec(), and usbscan_exec().
| int parse_parameters | ( | char * | text, |
| struct parameters ** | params | ||
| ) |
Parse request parameter list name.
| text | Text |
| params | Parameter list |
| rc | Return status code |
Definition at line 348 of file parseopt.c.
References ENOENT, find_parameters(), and printf().
Referenced by param_exec().
| void print_usage | ( | struct command_descriptor * | cmd, |
| char ** | argv | ||
| ) |
Print command usage message.
| cmd | Command descriptor |
| argv | Argument list |
Definition at line 370 of file parseopt.c.
References cmd, option::has_arg, optional_argument, printf(), and PRODUCT_COMMAND_URI.
Referenced by reparse_options().
| int reparse_options | ( | int | argc, |
| char ** | argv, | ||
| struct command_descriptor * | cmd, | ||
| void * | opts | ||
| ) |
Reparse command-line options.
| argc | Argument count |
| argv | Argument list |
| cmd | Command descriptor |
| opts | Options (already initialised with default values) |
| rc | Return status code |
Definition at line 401 of file parseopt.c.
References assert(), cmd, DBGC, ECANCELED_NO_OP, EINVAL_MISSING_ARGUMENT, EINVAL_UNKNOWN_OPTION, ERANGE, getopt_long(), option::has_arg, memset(), option::name, NULL, optarg, optind, optional_argument, opts, print_usage(), rc, option::val, and value.
Referenced by colour_exec(), cpair_exec(), parse_options(), ping_exec(), and sanboot_core_exec().
| int parse_options | ( | int | argc, |
| char ** | argv, | ||
| struct command_descriptor * | cmd, | ||
| void * | opts | ||
| ) |
Parse command-line options.
| argc | Argument count |
| argv | Argument list |
| cmd | Command descriptor |
| opts | Options (may be uninitialised) |
| rc | Return status code |
Definition at line 484 of file parseopt.c.
References cmd, memset(), opts, and reparse_options().
Referenced by cert_exec(), choose_exec(), config_exec(), console_exec(), cpuid_exec(), digest_exec(), dynui_exec(), echo_exec(), exit_exec(), fcels_exec(), fcstat_exec(), fdt_exec(), gdbstub_exec(), goto_exec(), ibstat_exec(), ifcommon_exec(), imgdecrypt_exec(), imgextract_exec(), imgmem_exec(), imgmulti_exec(), imgsingle_exec(), imgtrust_exec(), imgverify_exec(), inc_exec(), ipstat_exec(), iseq_exec(), isset_exec(), item_exec(), login_exec(), lotest_exec(), nslookup_exec(), nstat_exec(), ntp_exec(), param_exec(), params_exec(), pciscan_exec(), poweroff_exec(), present_exec(), profstat_exec(), prompt_exec(), pxebs_exec(), reboot_exec(), route_exec(), set_core_exec(), shell_exec(), shim_exec(), show_exec(), sleep_exec(), stoppxe_exec(), sync_exec(), time_exec(), usbscan_exec(), vcreate_exec(), and vdestroy_exec().
1.8.15