|
iPXE
|
Parse command-line options. More...
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static const char * | get_argv_argument (int argc, char *const argv[]) |
| Get option argument from argv[] array. More... | |
| static int | match_long_option (int argc, char *const argv[], const char *opttext, const struct option *longopt, int *option) |
| Match long option. More... | |
| static int | match_short_option (int argc, char *const argv[], const char *opttext, int shortopt, enum getopt_argument_requirement has_arg, int *option) |
| Match short option. More... | |
| int | getopt_long (int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) |
| Parse command-line options. 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.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Get option argument from argv[] array.
| argc | Argument count |
| argv | Argument list |
| argument | Option argument, or NULL |
Grab the next element of argv[], if it exists and is not an option.
Consume this argv element, and return it
Definition at line 77 of file getopt.c.
Referenced by match_long_option(), and match_short_option().
|
static |
Match long option.
| argc | Argument count |
| argv | Argument list |
| opttext | Option text within current argv[] element |
| longopt | Long option specification |
| option | Option to return from getopt() |
| matched | Found a match for this long option |
Definition at line 106 of file getopt.c.
References option::flag, get_argv_argument(), option::has_arg, option::name, no_argument, NULL, optarg, optind, printf(), required_argument, strlen(), strncmp(), and option::val.
Referenced by getopt_long().
|
static |
Match short option.
| argc | Argument count |
| argv | Argument list |
| opttext | Option text within current argv[] element |
| shortopt | Option character from option specification |
| option | Option to return from getopt() |
| matched | Found a match for this short option |
Definition at line 170 of file getopt.c.
References get_argv_argument(), nextchar, no_argument, NULL, optarg, optind, printf(), and required_argument.
Referenced by getopt_long().
| 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().
| 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