iPXE
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)
#define COMMAND(name, exec)

Functions

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

Macro Definition Documentation

◆ COMMANDS

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

Definition at line 23 of file command.h.

Referenced by execv(), and help_exec().

◆ __command

#define __command ( name)
Value:
const char * name
Definition ath9k_hw.c:1986
#define COMMANDS
Definition command.h:23
#define _C2(x, y)
Concatenate expanded arguments.
Definition compiler.h:48
#define __table_entry(table, idx)
Declare a linker table entry.
Definition tables.h:239

Definition at line 25 of file command.h.

◆ COMMAND

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

Definition at line 27 of file command.h.

27#define COMMAND( name, exec ) \
28 struct command name ## _command __command ( name ) = { \
29 #name, exec \
30 }

Referenced by epic100_probe().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ concat_args()

char * concat_args ( char ** args)
extern

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 NULL
NULL pointer (VOID *)
Definition Base.h:322
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
ring len
Length.
Definition dwmac.h:226
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
uint32_t string
Definition multiboot.h:2
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition stdio.h:37
size_t strlen(const char *src)
Get length of string.
Definition string.c:244

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