|
iPXE
|
Parse command-line options. More...
#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | option |
| A long option, as used for getopt_long() More... | |
Enumerations | |
| enum | getopt_argument_requirement { no_argument = 0, required_argument = 1, optional_argument = 2 } |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| int | getopt_long (int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) |
| Parse command-line options. More... | |
| static int | getopt (int argc, char *const argv[], const char *optstring) |
| Parse command-line options. More... | |
| static void | reset_getopt (void) |
| Reset getopt() internal state. More... | |
Variables | |
| char * | optarg |
| Option argument. More... | |
| int | optind |
| Current option index. More... | |
| int | nextchar |
| Current option character index. More... | |
| int | optopt |
| Unrecognised option. More... | |
Parse command-line options.
Definition in file getopt.h.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| int getopt_long | ( | int | argc, |
| char *const | argv[], | ||
| const char * | optstring, | ||
| const struct option * | longopts, | ||
| int * | longindex | ||
| ) |
Parse command-line options.
| argc | Argument count |
| argv | Argument list |
| optstring | Option specification string |
| longopts | Long option specification table |
| longindex | Index of long option (or NULL) |
| option | Option found, or -1 for no more options |
Note that the caller must arrange for reset_getopt() to be called before each set of calls to getopt_long(). In Etherboot, this is done automatically by execv().
Definition at line 229 of file getopt.c.
References option::has_arg, match_long_option(), match_short_option(), option::name, nextchar, no_argument, optind, optopt, and printf().
Referenced by getopt(), linux_args_parse(), and reparse_options().
|
inlinestatic |
Parse command-line options.
| argv | Argument count |
| argv | Argument list |
| optstring | Option specification string |
| option | Option found, or -1 for no more options |
See getopt_long() for full details.
Definition at line 70 of file getopt.h.
References getopt_long(), and NULL.
|
inlinestatic |
Reset getopt() internal state.
Due to a limitation of the POSIX getopt() API, it is necessary to add a call to reset_getopt() before each set of calls to getopt() or getopt_long(). This arises because POSIX assumes that each process will parse command line arguments no more than once; this assumption is not valid within Etherboot. We work around the limitation by arranging for execv() to call reset_getopt() before executing the command.
Definition at line 89 of file getopt.h.
References nextchar, and optind.
Referenced by execv(), and linux_args_parse().
| char* optarg |
Option argument.
This will point to the argument for the most recently returned option, if applicable.
Definition at line 43 of file getopt.c.
Referenced by linux_args_parse(), match_long_option(), match_short_option(), and reparse_options().
| int optind |
Current option index.
This is an index into the argv[] array. When getopt() returns -1, optind is the index to the first element that is not an option.
Definition at line 51 of file getopt.c.
Referenced by cert_exec(), choose_exec(), colour_exec(), config_exec(), cpair_exec(), cpuid_exec(), digest_exec(), dynui_exec(), echo_exec(), exit_exec(), fcels_exec(), fdt_exec(), gdbstub_exec(), get_argv_argument(), getopt_long(), goto_exec(), ifcommon_exec(), imgdecrypt_exec(), imgextract_exec(), imgmem_exec(), imgmulti_exec(), imgsingle_exec(), imgverify_exec(), inc_exec(), iseq_exec(), isset_exec(), item_exec(), lotest_exec(), match_long_option(), match_short_option(), nslookup_exec(), ntp_exec(), param_exec(), pciscan_exec(), ping_exec(), prompt_exec(), pxebs_exec(), reparse_options(), reset_getopt(), sanboot_core_exec(), set_core_exec(), shim_exec(), show_exec(), sleep_exec(), usbscan_exec(), vcreate_exec(), and vdestroy_exec().
| int nextchar |
Current option character index.
This is an index into the current element of argv[].
Definition at line 58 of file getopt.c.
Referenced by getopt_long(), match_short_option(), and reset_getopt().
| int optopt |
Unrecognised option.
When an unrecognised option is encountered, the actual option character is stored in optopt.
Definition at line 66 of file getopt.c.
Referenced by getopt_long().
1.8.15