iPXE
Data Structures | Defines | 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...

Defines

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

Functions

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

Define Documentation

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

Definition at line 22 of file command.h.

Referenced by execv(), and help_exec().

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

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

                                   {
        char **arg;
        size_t len;
        char *string;
        char *ptr;

        /* Calculate total string length */
        len = 1 /* NUL */;
        for ( arg = args ; *arg ; arg++ )
                len += ( 1 /* possible space */ + strlen ( *arg ) );

        /* Allocate string */
        string = zalloc ( len );
        if ( ! string )
                return NULL;

        /* Populate string */
        ptr = string;
        for ( arg = args ; *arg ; arg++ ) {
                ptr += sprintf ( ptr, "%s%s",
                                 ( ( arg == args ) ? "" : " " ), *arg );
        }
        assert ( ptr < ( string + len ) );

        return string;
}