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(name)   __table_entry ( COMMANDS, _C2 ( 01., name ) )
 
#define COMMAND(name, exec)
 

Functions

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

Macro Definition Documentation

◆ COMMANDS

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

Definition at line 23 of file command.h.

◆ __command

#define __command (   name)    __table_entry ( COMMANDS, _C2 ( 01., name ) )

Definition at line 25 of file command.h.

◆ COMMAND

#define COMMAND (   name,
  exec 
)
Value:
struct command name ## _command __command ( name ) = { \
#name, exec \
}
const char * name
Definition: ath9k_hw.c:1986
A command-line command.
Definition: command.h:10
#define __command(name)
Definition: command.h:25

Definition at line 27 of file command.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

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