|
iPXE
|
Command line option parsing. More...
#include <stddef.h>#include <stdint.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include <errno.h>#include <getopt.h>#include <ipxe/uuid.h>#include <ipxe/netdevice.h>#include <ipxe/dynui.h>#include <ipxe/settings.h>#include <ipxe/params.h>#include <ipxe/timer.h>#include <ipxe/keys.h>#include <ipxe/parseopt.h>#include <config/branding.h>Go to the source code of this file.
Macros | |
| #define | ECANCELED_NO_OP __einfo_error ( EINFO_ECANCELED_NO_OP ) |
| Return status code for "--help" option. More... | |
| #define | EINFO_ECANCELED_NO_OP __einfo_uniqify ( EINFO_ECANCELED, 0x01, "Nothing to do" ) |
| #define | EINVAL_INTEGER __einfo_error ( EINFO_EINVAL_INTEGER ) |
| #define | EINFO_EINVAL_INTEGER __einfo_uniqify ( EINFO_EINVAL, 0x01, "Invalid integer value" ) |
| #define | EINVAL_UNKNOWN_OPTION __einfo_error ( EINFO_EINVAL_UNKNOWN_OPTION ) |
| #define | EINFO_EINVAL_UNKNOWN_OPTION __einfo_uniqify ( EINFO_EINVAL, 0x02, "Unrecognised option" ) |
| #define | EINVAL_MISSING_ARGUMENT __einfo_error ( EINFO_EINVAL_MISSING_ARGUMENT ) |
| #define | EINFO_EINVAL_MISSING_ARGUMENT __einfo_uniqify ( EINFO_EINVAL, 0x03, "Missing argument" ) |
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 **value) |
| 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.c.
| #define ECANCELED_NO_OP __einfo_error ( EINFO_ECANCELED_NO_OP ) |
Return status code for "--help" option.
Definition at line 51 of file parseopt.c.
| #define EINFO_ECANCELED_NO_OP __einfo_uniqify ( EINFO_ECANCELED, 0x01, "Nothing to do" ) |
Definition at line 52 of file parseopt.c.
| #define EINVAL_INTEGER __einfo_error ( EINFO_EINVAL_INTEGER ) |
Definition at line 56 of file parseopt.c.
| #define EINFO_EINVAL_INTEGER __einfo_uniqify ( EINFO_EINVAL, 0x01, "Invalid integer value" ) |
Definition at line 57 of file parseopt.c.
| #define EINVAL_UNKNOWN_OPTION __einfo_error ( EINFO_EINVAL_UNKNOWN_OPTION ) |
Definition at line 59 of file parseopt.c.
| #define EINFO_EINVAL_UNKNOWN_OPTION __einfo_uniqify ( EINFO_EINVAL, 0x02, "Unrecognised option" ) |
Definition at line 60 of file parseopt.c.
| #define EINVAL_MISSING_ARGUMENT __einfo_error ( EINFO_EINVAL_MISSING_ARGUMENT ) |
Definition at line 62 of file parseopt.c.
| #define EINFO_EINVAL_MISSING_ARGUMENT __einfo_uniqify ( EINFO_EINVAL, 0x03, "Missing argument" ) |
Definition at line 63 of file parseopt.c.
| 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