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... | |
static int | prompt_exec (int argc, char **argv) |
"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... | |
struct command goto_command | __command |
"goto" command 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, copy_from_user(), image::data, EINVAL, ENOMEM, free, isspace(), len, image::len, memchr_user(), 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 161 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 196 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 219 of file script.c.
References copy_from_user(), image::data, DBGC, ENOEXEC, isspace(), image::len, 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 277 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 301 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 312 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().
|
static |
"prompt" command
argc | Argument count |
argv | Argument list |
rc | Return status code |
Definition at line 382 of file script.c.
References concat_args(), ENOMEM, free, optind, opts, parse_options(), prompt(), prompt_cmd, and rc.
|
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 258 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 266 of file script.c.
Referenced by goto_exec(), and goto_find_label().
struct command prompt_command __command |
|
static |
"prompt" option list
|
static |
"prompt" command descriptor
Definition at line 371 of file script.c.
Referenced by prompt_exec().