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)
 
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...
 
static int exit_exec (int argc, char **argv)
 "exit" command More...
 
static int isset_exec (int argc, char **argv)
 "isset" command More...
 
static int iseq_exec (int argc, char **argv)
 "iseq" command More...
 
static int sleep_exec (int argc, char **argv)
 "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...
 
struct command echo_command __command
 "echo" command 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  )

◆ 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 60 of file exec.c.

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

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

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 152 of file exec.c.

152  {
153  return ( rc == 0 );
154 }
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 162 of file exec.c.

162  {
163  return ( rc != 0 );
164 }
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 172 of file exec.c.

172  {
173  return 1;
174 }

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 183 of file exec.c.

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

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 217 of file exec.c.

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

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 227 of file exec.c.

227  {
228  int stopped;
229 
230  /* Test to see if we need to stop */
231  stopped = ( stop_state >= stop );
232 
233  /* Consume stop state */
234  if ( stop_state <= stop )
235  stop_state = 0;
236 
237  return stopped;
238 }
static int stop_state
Shell stop state.
Definition: exec.c:48

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 248 of file exec.c.

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

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 272 of file exec.c.

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

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 287 of file exec.c.

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

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 358 of file exec.c.

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

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

Referenced by echo_exec(), imgsingle_exec(), item_exec(), menu_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 409 of file exec.c.

409  {
410  struct echo_options opts;
411  char *text;
412  int rc;
413 
414  /* Parse options */
415  if ( ( rc = parse_options ( argc, argv, &echo_cmd, &opts ) ) != 0 )
416  return rc;
417 
418  /* Parse text */
419  text = concat_args ( &argv[optind] );
420  if ( ! text )
421  return -ENOMEM;
422 
423  /* Print text */
424  printf ( "%s%s", text, ( opts.no_newline ? "" : "\n" ) );
425 
426  free ( text );
427  return 0;
428 }
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:464
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
#define ENOMEM
Not enough space.
Definition: errno.h:534
char * concat_args(char **args)
Concatenate arguments.
Definition: exec.c:358
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static union @437 opts
"cert<xxx>" option list
static struct command_descriptor echo_cmd
"echo" command descriptor
Definition: exec.c:398
"echo" options
Definition: exec.c:386

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

◆ 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 453 of file exec.c.

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

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

◆ 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 497 of file exec.c.

497  {
498  struct isset_options opts;
499  int rc;
500 
501  /* Parse options */
502  if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
503  return rc;
504 
505  /* Return success iff argument is non-empty */
506  return ( argv[optind][0] ? 0 : -ENOENT );
507 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
#define ENOENT
No such file or directory.
Definition: errno.h:514
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
"isset" options
Definition: exec.c:481
static struct command_descriptor isset_cmd
"isset" command descriptor
Definition: exec.c:487
static union @437 opts
"cert<xxx>" option list

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

◆ 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 533 of file exec.c.

533  {
534  struct iseq_options opts;
535  int rc;
536 
537  /* Parse options */
538  if ( ( rc = parse_options ( argc, argv, &iseq_cmd, &opts ) ) != 0 )
539  return rc;
540 
541  /* Return success iff arguments are equal */
542  return ( ( strcmp ( argv[optind], argv[ optind + 1 ] ) == 0 ) ?
543  0 : -ERANGE );
544 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
"iseq" options
Definition: exec.c:516
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
#define ERANGE
Result too large.
Definition: errno.h:639
static union @437 opts
"cert<xxx>" option list
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
static struct command_descriptor iseq_cmd
"iseq" command descriptor
Definition: exec.c:522

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

◆ 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 569 of file exec.c.

569  {
570  struct sleep_options opts;
571  unsigned int seconds;
572  int rc;
573 
574  /* Parse options */
575  if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
576  return rc;
577 
578  /* Parse number of seconds */
579  if ( ( rc = parse_integer ( argv[optind], &seconds ) ) != 0 )
580  return rc;
581 
582  /* Delay for specified number of seconds */
583  if ( sleep ( seconds ) != 0 )
584  return -ECANCELED;
585 
586  return 0;
587 }
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:91
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
static struct command_descriptor sleep_cmd
"sleep" command descriptor
Definition: exec.c:559
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
#define ECANCELED
Operation canceled.
Definition: errno.h:343
"sleep" options
Definition: exec.c:553
static union @437 opts
"cert<xxx>" option list
UINT16_t seconds
Elapsed time.
Definition: pxe_api.h:81
unsigned int sleep(unsigned int secs)
Sleep (interruptibly) for a fixed number of seconds.
Definition: timer.c:133

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

Variable Documentation

◆ stop_state

int stop_state
static

Shell stop state.

Definition at line 48 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:226
Option does not take an argument.
Definition: getopt.h:16
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:67
"echo" options
Definition: exec.c:386

"echo" option list

Definition at line 392 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:392
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:97
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
"echo" options
Definition: exec.c:386

"echo" command descriptor

Definition at line 398 of file exec.c.

Referenced by echo_exec().

◆ __command

struct command sleep_command __command
Initial value:
= {
.name = "echo",
.exec = echo_exec,
}
static int echo_exec(int argc, char **argv)
"echo" command
Definition: exec.c:409

"echo" command

"sleep" command

"iseq" command

"isset" command

"exit" command

Definition at line 431 of file exec.c.

◆ exit_opts

struct option_descriptor exit_opts[] = {}
static

"exit" option list

Definition at line 440 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:440
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
"exit" options
Definition: exec.c:437

"exit" command descriptor

Definition at line 443 of file exec.c.

Referenced by exit_exec().

◆ isset_opts

struct option_descriptor isset_opts[] = {}
static

"isset" option list

Definition at line 484 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:481
static struct option_descriptor isset_opts[]
"isset" option list
Definition: exec.c:484
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108

"isset" command descriptor

Definition at line 487 of file exec.c.

Referenced by isset_exec().

◆ iseq_opts

struct option_descriptor iseq_opts[] = {}
static

"iseq" option list

Definition at line 519 of file exec.c.

◆ iseq_cmd

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

"iseq" command descriptor

Definition at line 522 of file exec.c.

Referenced by iseq_exec().

◆ sleep_opts

struct option_descriptor sleep_opts[] = {}
static

"sleep" option list

Definition at line 556 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:556
"sleep" options
Definition: exec.c:553
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108

"sleep" command descriptor

Definition at line 559 of file exec.c.

Referenced by sleep_exec().