|
iPXE
|
iPXE scripts More...
#include <string.h>#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <errno.h>#include <getopt.h>#include <ipxe/command.h>#include <ipxe/parseopt.h>#include <ipxe/image.h>#include <ipxe/shell.h>#include <usr/prompt.h>#include <ipxe/script.h>Go to the source code of this file.
Data Structures | |
| struct | goto_options |
| "goto" options More... | |
| struct | prompt_options |
| "prompt" options More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static int | process_script (struct image *image, int(*process_line)(struct image *image, size_t offset, const char *label, const char *command), int(*terminate)(int rc)) |
| Process script lines. More... | |
| static int | terminate_on_exit_or_failure (int rc) |
| Terminate script processing on shell exit or command failure. More... | |
| static int | script_exec_line (struct image *image, size_t offset, const char *label __unused, const char *command) |
| Execute script line. More... | |
| static int | script_exec (struct image *image) |
| Execute script. More... | |
| static int | script_probe (struct image *image) |
| Probe script image. More... | |
| struct image_type script_image_type | __image_type (PROBE_NORMAL) |
| Script image type. More... | |
| static int | goto_find_label (struct image *image, size_t offset, const char *label, const char *command __unused) |
| Check for presence of label. More... | |
| static int | terminate_on_label_found (int rc) |
| Terminate script processing when label is found. More... | |
| static int | goto_exec (int argc, char **argv) |
| "goto" command More... | |
| COMMAND (goto, goto_exec) | |
| "goto" command More... | |
| static int | prompt_exec (int argc, char **argv) |
| "prompt" command More... | |
| COMMAND (prompt, prompt_exec) | |
| "prompt" command More... | |
Variables | |
| static size_t | script_offset |
| Offset within current script. More... | |
| static struct option_descriptor | goto_opts [] = {} |
| "goto" option list More... | |
| static struct command_descriptor | goto_cmd |
| "goto" command descriptor More... | |
| static const char * | goto_label |
| Current "goto" label. More... | |
| static struct option_descriptor | prompt_opts [] |
| "prompt" option list More... | |
| static struct command_descriptor | prompt_cmd |
| "prompt" command descriptor More... | |
iPXE scripts
Definition in file script.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Process script lines.
| image | Script |
| process_line | Line processor |
| terminate | Termination check |
| rc | Return status code |
Definition at line 61 of file script.c.
References command, image::data, EINVAL, ENOMEM, free, isspace(), image::len, len, memchr(), memcpy(), NULL, rc, realloc(), script_offset, and tmp.
Referenced by goto_exec(), and script_exec().
|
static |
Terminate script processing on shell exit or command failure.
| rc | Line processing status |
| terminate | Terminate script processing |
Definition at line 163 of file script.c.
References rc, SHELL_STOP_COMMAND_SEQUENCE, and shell_stopped().
Referenced by script_exec().
|
static |
|
static |
Execute script.
| image | Script |
| rc | Return status code |
Definition at line 198 of file script.c.
References process_script(), rc, script_exec_line(), script_offset, and terminate_on_exit_or_failure().
|
static |
Probe script image.
| image | Script |
| rc | Return status code |
Definition at line 221 of file script.c.
References __attribute__, image::data, DBGC, ENOEXEC, isspace(), image::len, magic, memcmp(), static_assert, and test.
| struct image_type script_image_type __image_type | ( | PROBE_NORMAL | ) |
Script image type.
|
static |
Check for presence of label.
| image | Script |
| offset | Offset within script |
| label | Label |
| command | Command |
| rc | Return status code |
Definition at line 283 of file script.c.
References DBGC, ENOENT, goto_label, offset, script_offset, and strcmp().
Referenced by goto_exec().
|
static |
Terminate script processing when label is found.
| rc | Line processing status |
| terminate | Terminate script processing |
Definition at line 307 of file script.c.
References rc.
Referenced by goto_exec().
|
static |
"goto" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 318 of file script.c.
References current_image, DBGC, ENOTTY, goto_cmd, goto_find_label(), goto_label, image_tag::image, optind, opts, parse_options(), printf(), process_script(), rc, script_offset, shell_stop(), SHELL_STOP_COMMAND, strerror(), and terminate_on_label_found().
| COMMAND | ( | goto | , |
| goto_exec | |||
| ) |
"goto" command
|
static |
"prompt" command
| argc | Argument count |
| argv | Argument list |
| rc | Return status code |
Definition at line 385 of file script.c.
References concat_args(), ENOMEM, free, optind, opts, parse_options(), prompt(), prompt_cmd, and rc.
| COMMAND | ( | prompt | , |
| prompt_exec | |||
| ) |
"prompt" command
|
static |
Offset within current script.
This is a global in order to allow goto_exec() to update the offset.
Definition at line 51 of file script.c.
Referenced by goto_exec(), goto_find_label(), process_script(), and script_exec().
|
static |
|
static |
"goto" command descriptor
Definition at line 264 of file script.c.
Referenced by goto_exec().
|
static |
Current "goto" label.
Valid only during goto_exec(). Consider this part of a closure.
Definition at line 272 of file script.c.
Referenced by goto_exec(), and goto_find_label().
|
static |
"prompt" option list
|
static |
"prompt" command descriptor
Definition at line 374 of file script.c.
Referenced by prompt_exec().
1.8.15