iPXE
Enumerations | Functions
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. More...
 
int shell_stopped (int stop)
 Test and consume shell stop state. More...
 
int shell (void)
 Start command shell. More...
 

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 */
16  SHELL_CONTINUE = 0,
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 };
Continue processing.
Definition: shell.h:16
Stop processing current command line.
Definition: shell.h:23
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)

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)

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 }
static int stop_state
Shell stop state.
Definition: exec.c:49

References stop_state.

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

◆ shell()

int shell ( void  )

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
A readline history buffer.
Definition: readline.h:32
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 const char shell_prompt[]
The shell prompt string.
Definition: shell.c:45
int shell_stopped(int stop)
Test and consume shell stop state.
Definition: exec.c:228
void history_free(struct readline_history *history)
Free history buffer.
Definition: readline.c:232
Stop processing commands.
Definition: shell.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:25
void * memset(void *dest, int character, size_t len) __nonnull

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

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