iPXE
Data Structures | Macros | Functions
command.h File Reference
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  command
 A command-line command. More...
 

Macros

#define COMMANDS   __table ( struct command, "commands" )
 
#define __command   __table_entry ( COMMANDS, 01 )
 "exit" command More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
char * concat_args (char **args)
 Concatenate arguments. More...
 

Macro Definition Documentation

◆ COMMANDS

#define COMMANDS   __table ( struct command, "commands" )

Definition at line 22 of file command.h.

◆ __command

struct command shell_command __command   __table_entry ( COMMANDS, 01 )

"exit" command

"shell" command

"prompt" command

"sleep" command

"iseq" command

"isset" command

Definition at line 24 of file command.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

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