iPXE
Data Structures | Functions | Variables
exec.c File Reference

Command execution. More...

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/tables.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/settings.h>
#include <ipxe/shell.h>

Go to the source code of this file.

Data Structures

struct  echo_options
 "echo" options More...
 
struct  exit_options
 "exit" options More...
 
struct  isset_options
 "isset" options More...
 
struct  iseq_options
 "iseq" options More...
 
struct  sleep_options
 "sleep" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
int execv (const char *command, char *const argv[])
 Execute command. More...
 
static int split_command (char *command, char **tokens)
 Split command line into tokens. More...
 
static int process_on_success (int rc)
 Process next command only if previous command succeeded. More...
 
static int process_on_failure (int rc)
 Process next command only if previous command failed. More...
 
static int process_always (int rc __unused)
 Process next command regardless of status from previous command. More...
 
static int command_terminator (char **tokens, int(**process_next)(int rc))
 Find command terminator. More...
 
void shell_stop (int stop)
 Set shell stop state. More...
 
int shell_stopped (int stop)
 Test and consume shell stop state. More...
 
static int expand_tokens (int argc, char **tokens, char **argv)
 Expand settings within a token list. More...
 
static void free_tokens (char **argv)
 Free an expanded token list. More...
 
int system (const char *command)
 Execute command line. More...
 
char * concat_args (char **args)
 Concatenate arguments. More...
 
static int echo_exec (int argc, char **argv)
 "echo" command More...
 
 COMMAND (echo, echo_exec)
 "echo" command More...
 
static int exit_exec (int argc, char **argv)
 "exit" command More...
 
 COMMAND (exit, exit_exec)
 "exit" command More...
 
static int isset_exec (int argc, char **argv)
 "isset" command More...
 
 COMMAND (isset, isset_exec)
 "isset" command More...
 
static int iseq_exec (int argc, char **argv)
 "iseq" command More...
 
 COMMAND (iseq, iseq_exec)
 "iseq" command More...
 
static int sleep_exec (int argc, char **argv)
 "sleep" command More...
 
 COMMAND (sleep, sleep_exec)
 "sleep" command More...
 

Variables

static int stop_state
 Shell stop state. More...
 
static struct option_descriptor echo_opts []
 "echo" option list More...
 
static struct command_descriptor echo_cmd
 "echo" command descriptor More...
 
static struct option_descriptor exit_opts [] = {}
 "exit" option list More...
 
static struct command_descriptor exit_cmd
 "exit" command descriptor More...
 
static struct option_descriptor isset_opts [] = {}
 "isset" option list More...
 
static struct command_descriptor isset_cmd
 "isset" command descriptor More...
 
static struct option_descriptor iseq_opts [] = {}
 "iseq" option list More...
 
static struct command_descriptor iseq_cmd
 "iseq" command descriptor More...
 
static struct option_descriptor sleep_opts [] = {}
 "sleep" option list More...
 
static struct command_descriptor sleep_cmd
 "sleep" command descriptor More...
 

Detailed Description

Command execution.

Definition in file exec.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ execv()

int execv ( const char *  command,
char *const  argv[] 
)

Execute command.

Parameters
commandCommand name
argvArgument list
Return values
rcReturn status code

Execute the named command. Unlike a traditional POSIX execv(), this function returns the exit status of the command.

Definition at line 61 of file exec.c.

61  {
62  struct command *cmd;
63  int argc;
64  int rc;
65 
66  /* Count number of arguments */
67  for ( argc = 0 ; argv[argc] ; argc++ ) {}
68 
69  /* An empty command is deemed to do nothing, successfully */
70  if ( command == NULL ) {
71  rc = 0;
72  goto done;
73  }
74 
75  /* Sanity checks */
76  if ( argc == 0 ) {
77  DBG ( "%s: empty argument list\n", command );
78  rc = -EINVAL;
79  goto done;
80  }
81 
82  /* Reset getopt() library ready for use by the command. This
83  * is an artefact of the POSIX getopt() API within the context
84  * of Etherboot; see the documentation for reset_getopt() for
85  * details.
86  */
87  reset_getopt();
88 
89  /* Hand off to command implementation */
91  if ( strcmp ( command, cmd->name ) == 0 ) {
92  rc = cmd->exec ( argc, ( char ** ) argv );
93  goto done;
94  }
95  }
96 
97  printf ( "%s: command not found\n", command );
98  rc = -ENOEXEC;
99 
100  done:
101  /* Store error number, if an error occurred */
102  if ( rc ) {
103  errno = rc;
104  if ( errno < 0 )
105  errno = -errno;
106  }
107 
108  return rc;
109 }
#define EINVAL
Invalid argument.
Definition: errno.h:429
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
A command-line command.
Definition: command.h:10
#define ENOEXEC
Exec format error.
Definition: errno.h:520
int errno
Global "last error" number.
Definition: errno.c:21
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:386
static void reset_getopt(void)
Reset getopt() internal state.
Definition: getopt.h:90
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
#define COMMANDS
Definition: command.h:23
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct bofm_section_header done
Definition: bofm_test.c:46

References cmd, COMMANDS, DBG, done, EINVAL, ENOEXEC, errno, for_each_table_entry, NULL, printf(), rc, reset_getopt(), and strcmp().

Referenced by system(), and time_exec().

◆ split_command()

static int split_command ( char *  command,
char **  tokens 
)
static

Split command line into tokens.

Parameters
commandCommand line
tokensToken list to populate, or NULL
Return values
countNumber of tokens

Splits the command line into whitespace-delimited tokens. If tokens is non-NULL, any whitespace in the command line will be replaced with NULs.

Definition at line 122 of file exec.c.

122  {
123  int count = 0;
124 
125  while ( 1 ) {
126  /* Skip over any whitespace / convert to NUL */
127  while ( isspace ( *command ) ) {
128  if ( tokens )
129  *command = '\0';
130  command++;
131  }
132  /* Check for end of line */
133  if ( ! *command )
134  break;
135  /* We have found the start of the next argument */
136  if ( tokens )
137  tokens[count] = command;
138  count++;
139  /* Skip to start of next whitespace, if any */
140  while ( *command && ! isspace ( *command ) ) {
141  command++;
142  }
143  }
144  return count;
145 }
A command-line command.
Definition: command.h:10
static unsigned int count
Number of entries.
Definition: dwmac.h:225
int isspace(int character)
Check to see if character is a space.
Definition: ctype.c:42
static int command
Definition: epic100.c:68

References command, count, and isspace().

Referenced by system().

◆ process_on_success()

static int process_on_success ( int  rc)
static

Process next command only if previous command succeeded.

Parameters
rcStatus of previous command
Return values
processProcess next command

Definition at line 153 of file exec.c.

153  {
154  return ( rc == 0 );
155 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14

References rc.

Referenced by command_terminator().

◆ process_on_failure()

static int process_on_failure ( int  rc)
static

Process next command only if previous command failed.

Parameters
rcStatus of previous command
Return values
processProcess next command

Definition at line 163 of file exec.c.

163  {
164  return ( rc != 0 );
165 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14

References rc.

Referenced by command_terminator().

◆ process_always()

static int process_always ( int rc  __unused)
static

Process next command regardless of status from previous command.

Parameters
rcStatus of previous command
Return values
processProcess next command

Definition at line 173 of file exec.c.

173  {
174  return 1;
175 }

Referenced by command_terminator().

◆ command_terminator()

static int command_terminator ( char **  tokens,
int(**)(int rc process_next 
)
static

Find command terminator.

Parameters
tokensToken list
Return values
process_next"Should next command be processed?" function
argcArgument count

Definition at line 184 of file exec.c.

185  {
186  unsigned int i;
187 
188  /* Find first terminating token */
189  for ( i = 0 ; tokens[i] ; i++ ) {
190  if ( tokens[i][0] == '#' ) {
191  /* Start of a comment */
192  break;
193  } else if ( strcmp ( tokens[i], "||" ) == 0 ) {
194  /* Short-circuit logical OR */
195  *process_next = process_on_failure;
196  return i;
197  } else if ( strcmp ( tokens[i], "&&" ) == 0 ) {
198  /* Short-circuit logical AND */
199  *process_next = process_on_success;
200  return i;
201  } else if ( strcmp ( tokens[i], ";" ) == 0 ) {
202  /* Process next command unconditionally */
203  *process_next = process_always;
204  return i;
205  }
206  }
207 
208  /* End of token list */
209  *process_next = NULL;
210  return i;
211 }
static int process_always(int rc __unused)
Process next command regardless of status from previous command.
Definition: exec.c:173
static int process_on_failure(int rc)
Process next command only if previous command failed.
Definition: exec.c:163
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
static int process_on_success(int rc)
Process next command only if previous command succeeded.
Definition: exec.c:153
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References NULL, process_always(), process_on_failure(), process_on_success(), and strcmp().

Referenced by system().

◆ 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().

◆ expand_tokens()

static int expand_tokens ( int  argc,
char **  tokens,
char **  argv 
)
static

Expand settings within a token list.

Parameters
argcArgument count
tokensToken list
argvArgument list to fill in
Return values
rcReturn status code

Definition at line 249 of file exec.c.

249  {
250  int i;
251 
252  /* Expand each token in turn */
253  for ( i = 0 ; i < argc ; i++ ) {
254  argv[i] = expand_settings ( tokens[i] );
255  if ( ! argv[i] )
256  goto err_expand_settings;
257  }
258 
259  return 0;
260 
261  err_expand_settings:
262  assert ( argv[i] == NULL );
263  for ( ; i >= 0 ; i-- )
264  free ( argv[i] );
265  return -ENOMEM;
266 }
char * expand_settings(const char *string)
Expand variables within string.
Definition: settings.c:2331
#define ENOMEM
Not enough space.
Definition: errno.h:535
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References assert(), ENOMEM, expand_settings(), free, and NULL.

Referenced by system().

◆ free_tokens()

static void free_tokens ( char **  argv)
static

Free an expanded token list.

Parameters
argvArgument list

Definition at line 273 of file exec.c.

273  {
274 
275  /* Free each expanded argument */
276  while ( *argv )
277  free ( *(argv++) );
278 }
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55

References free.

Referenced by system().

◆ system()

int system ( const char *  command)

Execute command line.

Parameters
commandCommand line
Return values
rcReturn status code

Execute the named command and arguments.

Definition at line 288 of file exec.c.

288  {
289  int count = split_command ( ( char * ) command, NULL );
290  char *all_tokens[ count + 1 ];
291  int ( * process_next ) ( int rc );
292  char *command_copy;
293  char **tokens;
294  int argc;
295  int process;
296  int rc = 0;
297 
298  /* Create modifiable copy of command */
299  command_copy = strdup ( command );
300  if ( ! command_copy )
301  return -ENOMEM;
302 
303  /* Split command into tokens */
304  split_command ( command_copy, all_tokens );
305  all_tokens[count] = NULL;
306 
307  /* Process individual commands */
308  process = 1;
309  for ( tokens = all_tokens ; ; tokens += ( argc + 1 ) ) {
310 
311  /* Find command terminator */
312  argc = command_terminator ( tokens, &process_next );
313 
314  /* Expand tokens and execute command */
315  if ( process ) {
316  char *argv[ argc + 1 ];
317 
318  /* Expand tokens */
319  if ( ( rc = expand_tokens ( argc, tokens, argv ) ) != 0)
320  break;
321  argv[argc] = NULL;
322 
323  /* Execute command */
324  rc = execv ( argv[0], argv );
325 
326  /* Free tokens */
327  free_tokens ( argv );
328  }
329 
330  /* Stop processing, if applicable */
332  break;
333 
334  /* Stop processing if we have reached the end of the
335  * command.
336  */
337  if ( ! process_next )
338  break;
339 
340  /* Determine whether or not to process next command */
341  process = process_next ( rc );
342  }
343 
344  /* Free modified copy of command */
345  free ( command_copy );
346 
347  return rc;
348 }
A process.
Definition: process.h:18
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A command-line command.
Definition: command.h:10
static void free_tokens(char **argv)
Free an expanded token list.
Definition: exec.c:273
static int expand_tokens(int argc, char **tokens, char **argv)
Expand settings within a token list.
Definition: exec.c:249
#define ENOMEM
Not enough space.
Definition: errno.h:535
Stop processing current command line.
Definition: shell.h:23
static unsigned int count
Number of entries.
Definition: dwmac.h:225
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
char * strdup(const char *src)
Duplicate string.
Definition: string.c:394
int shell_stopped(int stop)
Test and consume shell stop state.
Definition: exec.c:228
static int command_terminator(char **tokens, int(**process_next)(int rc))
Find command terminator.
Definition: exec.c:184
static int split_command(char *command, char **tokens)
Split command line into tokens.
Definition: exec.c:122
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
int execv(const char *command, char *const argv[])
Execute command.
Definition: exec.c:61

References command_terminator(), count, ENOMEM, execv(), expand_tokens(), free, free_tokens(), NULL, rc, SHELL_STOP_COMMAND, shell_stopped(), split_command(), and strdup().

◆ concat_args()

char* concat_args ( char **  args)

Concatenate arguments.

Parameters
argsArgument list (NULL-terminated)
Return values
stringConcatenated arguments

The returned string is allocated with malloc(). The caller is responsible for eventually free()ing this string.

Definition at line 359 of file exec.c.

359  {
360  char **arg;
361  size_t len;
362  char *string;
363  char *ptr;
364 
365  /* Calculate total string length */
366  len = 1 /* NUL */;
367  for ( arg = args ; *arg ; arg++ )
368  len += ( 1 /* possible space */ + strlen ( *arg ) );
369 
370  /* Allocate string */
371  string = zalloc ( len );
372  if ( ! string )
373  return NULL;
374 
375  /* Populate string */
376  ptr = string;
377  for ( arg = args ; *arg ; arg++ ) {
378  ptr += sprintf ( ptr, "%s%s",
379  ( ( arg == args ) ? "" : " " ), *arg );
380  }
381  assert ( ptr < ( string + len ) );
382 
383  return string;
384 }
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition: stdio.h:37
uint32_t string
Definition: multiboot.h:14
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:662
size_t strlen(const char *src)
Get length of string.
Definition: string.c:244
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References assert(), len, NULL, sprintf, string, strlen(), and zalloc().

Referenced by dynui_exec(), echo_exec(), imgsingle_exec(), item_exec(), param_exec(), prompt_exec(), and set_value().

◆ echo_exec()

static int echo_exec ( int  argc,
char **  argv 
)
static

"echo" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 410 of file exec.c.

410  {
411  struct echo_options opts;
412  char *text;
413  int rc;
414 
415  /* Parse options */
416  if ( ( rc = parse_options ( argc, argv, &echo_cmd, &opts ) ) != 0 )
417  return rc;
418 
419  /* Parse text */
420  text = concat_args ( &argv[optind] );
421  if ( ! text )
422  return -ENOMEM;
423 
424  /* Print text */
425  printf ( "%s%s", text, ( opts.no_newline ? "" : "\n" ) );
426 
427  free ( text );
428  return 0;
429 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
int optind
Current option index.
Definition: getopt.c:52
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
#define ENOMEM
Not enough space.
Definition: errno.h:535
char * concat_args(char **args)
Concatenate arguments.
Definition: exec.c:359
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
static struct command_descriptor echo_cmd
"echo" command descriptor
Definition: exec.c:399
static union @447 opts
"cert<xxx>" option list
"echo" options
Definition: exec.c:387

References concat_args(), echo_cmd, ENOMEM, free, optind, opts, parse_options(), printf(), and rc.

◆ COMMAND() [1/5]

COMMAND ( echo  ,
echo_exec   
)

"echo" command

◆ exit_exec()

static int exit_exec ( int  argc,
char **  argv 
)
static

"exit" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 451 of file exec.c.

451  {
452  struct exit_options opts;
453  unsigned int exit_code = 0;
454  int rc;
455 
456  /* Parse options */
457  if ( ( rc = parse_options ( argc, argv, &exit_cmd, &opts ) ) != 0 )
458  return rc;
459 
460  /* Parse exit status, if present */
461  if ( optind != argc ) {
462  if ( ( rc = parse_integer ( argv[optind], &exit_code ) ) != 0 )
463  return rc;
464  }
465 
466  /* Stop shell processing */
468 
469  return exit_code;
470 }
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:92
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:52
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
void shell_stop(int stop)
Set shell stop state.
Definition: exec.c:218
static struct command_descriptor exit_cmd
"exit" command descriptor
Definition: exec.c:441
Stop processing commands.
Definition: shell.h:30
static union @447 opts
"cert<xxx>" option list
"exit" options
Definition: exec.c:435

References exit_cmd, optind, opts, parse_integer(), parse_options(), rc, shell_stop(), and SHELL_STOP_COMMAND_SEQUENCE.

◆ COMMAND() [2/5]

COMMAND ( exit  ,
exit_exec   
)

"exit" command

◆ isset_exec()

static int isset_exec ( int  argc,
char **  argv 
)
static

"isset" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 492 of file exec.c.

492  {
493  struct isset_options opts;
494  int rc;
495 
496  /* Parse options */
497  if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
498  return rc;
499 
500  /* Return success iff argument is non-empty */
501  return ( argv[optind][0] ? 0 : -ENOENT );
502 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:52
#define ENOENT
No such file or directory.
Definition: errno.h:515
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
"isset" options
Definition: exec.c:476
static struct command_descriptor isset_cmd
"isset" command descriptor
Definition: exec.c:482
static union @447 opts
"cert<xxx>" option list

References ENOENT, isset_cmd, optind, opts, parse_options(), and rc.

◆ COMMAND() [3/5]

COMMAND ( isset  ,
isset_exec   
)

"isset" command

◆ iseq_exec()

static int iseq_exec ( int  argc,
char **  argv 
)
static

"iseq" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 525 of file exec.c.

525  {
526  struct iseq_options opts;
527  int rc;
528 
529  /* Parse options */
530  if ( ( rc = parse_options ( argc, argv, &iseq_cmd, &opts ) ) != 0 )
531  return rc;
532 
533  /* Return success iff arguments are equal */
534  return ( ( strcmp ( argv[optind], argv[ optind + 1 ] ) == 0 ) ?
535  0 : -ERANGE );
536 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:52
"iseq" options
Definition: exec.c:508
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
#define ERANGE
Result too large.
Definition: errno.h:640
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
static union @447 opts
"cert<xxx>" option list
static struct command_descriptor iseq_cmd
"iseq" command descriptor
Definition: exec.c:514

References ERANGE, iseq_cmd, optind, opts, parse_options(), rc, and strcmp().

◆ COMMAND() [4/5]

COMMAND ( iseq  ,
iseq_exec   
)

"iseq" command

◆ sleep_exec()

static int sleep_exec ( int  argc,
char **  argv 
)
static

"sleep" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 558 of file exec.c.

558  {
559  struct sleep_options opts;
560  unsigned int seconds;
561  int rc;
562 
563  /* Parse options */
564  if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
565  return rc;
566 
567  /* Parse number of seconds */
568  if ( ( rc = parse_integer ( argv[optind], &seconds ) ) != 0 )
569  return rc;
570 
571  /* Delay for specified number of seconds */
572  if ( sleep ( seconds ) != 0 )
573  return -ECANCELED;
574 
575  return 0;
576 }
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:92
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:52
static struct command_descriptor sleep_cmd
"sleep" command descriptor
Definition: exec.c:548
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
#define ECANCELED
Operation canceled.
Definition: errno.h:344
"sleep" options
Definition: exec.c:542
UINT16_t seconds
Elapsed time.
Definition: pxe_api.h:81
static union @447 opts
"cert<xxx>" option list
unsigned int sleep(unsigned int secs)
Sleep (interruptibly) for a fixed number of seconds.
Definition: timer.c:134

References ECANCELED, optind, opts, parse_integer(), parse_options(), rc, seconds, sleep(), and sleep_cmd.

◆ COMMAND() [5/5]

COMMAND ( sleep  ,
sleep_exec   
)

"sleep" command

Variable Documentation

◆ stop_state

int stop_state
static

Shell stop state.

Definition at line 49 of file exec.c.

Referenced by shell_stop(), and shell_stopped().

◆ echo_opts

struct option_descriptor echo_opts[]
static
Initial value:
= {
OPTION_DESC ( "n", 'n', no_argument,
struct echo_options, no_newline, parse_flag ),
}
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:227
Option does not take an argument.
Definition: getopt.h:17
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:68
"echo" options
Definition: exec.c:387

"echo" option list

Definition at line 393 of file exec.c.

◆ echo_cmd

struct command_descriptor echo_cmd
static
Initial value:
=
"[...]" )
static struct option_descriptor echo_opts[]
"echo" option list
Definition: exec.c:393
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:98
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
"echo" options
Definition: exec.c:387

"echo" command descriptor

Definition at line 399 of file exec.c.

Referenced by echo_exec().

◆ exit_opts

struct option_descriptor exit_opts[] = {}
static

"exit" option list

Definition at line 438 of file exec.c.

◆ exit_cmd

struct command_descriptor exit_cmd
static
Initial value:
=
COMMAND_DESC ( struct exit_options, exit_opts, 0, 1, "[<status>]" )
static struct option_descriptor exit_opts[]
"exit" option list
Definition: exec.c:438
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
"exit" options
Definition: exec.c:435

"exit" command descriptor

Definition at line 441 of file exec.c.

Referenced by exit_exec().

◆ isset_opts

struct option_descriptor isset_opts[] = {}
static

"isset" option list

Definition at line 479 of file exec.c.

◆ isset_cmd

struct command_descriptor isset_cmd
static
Initial value:
=
COMMAND_DESC ( struct isset_options, isset_opts, 1, 1, "<value>" )
"isset" options
Definition: exec.c:476
static struct option_descriptor isset_opts[]
"isset" option list
Definition: exec.c:479
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109

"isset" command descriptor

Definition at line 482 of file exec.c.

Referenced by isset_exec().

◆ iseq_opts

struct option_descriptor iseq_opts[] = {}
static

"iseq" option list

Definition at line 511 of file exec.c.

◆ iseq_cmd

struct command_descriptor iseq_cmd
static
Initial value:
=
"<value1> <value2>" )
"iseq" options
Definition: exec.c:508
static struct option_descriptor iseq_opts[]
"iseq" option list
Definition: exec.c:511
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109

"iseq" command descriptor

Definition at line 514 of file exec.c.

Referenced by iseq_exec().

◆ sleep_opts

struct option_descriptor sleep_opts[] = {}
static

"sleep" option list

Definition at line 545 of file exec.c.

◆ sleep_cmd

struct command_descriptor sleep_cmd
static
Initial value:
=
COMMAND_DESC ( struct sleep_options, sleep_opts, 1, 1, "<seconds>" )
static struct option_descriptor sleep_opts[]
"sleep" option list
Definition: exec.c:545
"sleep" options
Definition: exec.c:542
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109

"sleep" command descriptor

Definition at line 548 of file exec.c.

Referenced by sleep_exec().