iPXE
shell.h File Reference

Minimal command shell. More...

Go to the source code of this file.

Enumerations

enum  shell_stop_state { SHELL_CONTINUE = 0 , SHELL_STOP_COMMAND = 1 , SHELL_STOP_COMMAND_SEQUENCE = 2 }
 Shell stop states. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
void shell_stop (int stop)
 Set shell stop state.
int shell_stopped (int stop)
 Test and consume shell stop state.
int shell (void)
 Start command shell.

Detailed Description

Minimal command shell.

Definition in file shell.h.

Enumeration Type Documentation

◆ shell_stop_state

Shell stop states.

Enumerator
SHELL_CONTINUE 

Continue processing.

SHELL_STOP_COMMAND 

Stop processing current command line.

This is the stop state entered by commands that change the flow of execution, such as "goto".

SHELL_STOP_COMMAND_SEQUENCE 

Stop processing commands.

This is the stop state entered by commands that terminate the flow of execution, such as "exit".

Definition at line 14 of file shell.h.

14 {
15 /** Continue processing */
17 /**
18 * Stop processing current command line
19 *
20 * This is the stop state entered by commands that change the flow
21 * of execution, such as "goto".
22 */
24 /**
25 * Stop processing commands
26 *
27 * This is the stop state entered by commands that terminate
28 * the flow of execution, such as "exit".
29 */
31};
@ SHELL_STOP_COMMAND
Stop processing current command line.
Definition shell.h:23
@ SHELL_CONTINUE
Continue processing.
Definition shell.h:16
@ SHELL_STOP_COMMAND_SEQUENCE
Stop processing commands.
Definition shell.h:30

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ shell_stop()

void shell_stop ( int stop)
extern

Set shell stop state.

Parameters
stopShell stop state

Definition at line 218 of file exec.c.

218 {
219 stop_state = stop;
220}
static int stop_state
Shell stop state.
Definition exec.c:49

References stop_state.

Referenced by exit_exec(), goto_exec(), and imgexec().

◆ shell_stopped()

int shell_stopped ( int stop)
extern

Test and consume shell stop state.

Parameters
stopShell stop state to consume
stoppedShell had been stopped

Definition at line 228 of file exec.c.

228 {
229 int stopped;
230
231 /* Test to see if we need to stop */
232 stopped = ( stop_state >= stop );
233
234 /* Consume stop state */
235 if ( stop_state <= stop )
236 stop_state = 0;
237
238 return stopped;
239}

References stop_state.

Referenced by shell(), system(), and terminate_on_exit_or_failure().

◆ shell()

int shell ( void )
extern

Start command shell.

Definition at line 82 of file shell.c.

82 {
83 struct readline_history history;
84 char *line;
85 int rc = 0;
86
87 /* Initialise shell history */
88 memset ( &history, 0, sizeof ( history ) );
89
90 /* Read and execute commands */
91 do {
92 readline_history ( shell_prompt, NULL, &history, 0, &line );
93 if ( line ) {
94 rc = system ( line );
95 free ( line );
96 }
98
99 /* Discard shell history */
100 history_free ( &history );
101
102 return rc;
103}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
uint8_t system[ETH_ALEN]
System identifier.
Definition eth_slow.h:13
int shell_stopped(int stop)
Test and consume shell stop state.
Definition exec.c:228
void * memset(void *dest, int character, size_t len) __nonnull
void history_free(struct readline_history *history)
Free history buffer.
Definition readline.c:232
int readline_history(const char *prompt, const char *prefill, struct readline_history *history, unsigned long timeout, char **line)
Read line from console (with history)
Definition readline.c:258
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
static const char shell_prompt[]
The shell prompt string.
Definition shell.c:45
A readline history buffer.
Definition readline.h:32

References free, history_free(), memset(), NULL, rc, readline_history(), shell_prompt, SHELL_STOP_COMMAND_SEQUENCE, shell_stopped(), and system.

Referenced by COMMAND(), interrupt(), ipxe(), PROVIDE_REQUIRING_SYMBOL(), and shell_exec().