iPXE
Data Structures | Functions | Variables
time_cmd.c File Reference

Time commands. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/timer.h>

Go to the source code of this file.

Data Structures

struct  time_options
 "time" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int time_exec (int argc, char **argv)
 "time" command

Variables

static struct option_descriptor time_opts [] = {}
 "time" option list
static struct command_descriptor time_cmd
 "time" command descriptor
struct command time_command __command
 "time" command

Detailed Description

Time commands.

Definition in file time_cmd.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
static int time_exec ( int  argc,
char **  argv 
) [static]

"time" command

Parameters:
argcArgument count
argvArgument list
Return values:
rcReturn status code

Definition at line 57 of file time_cmd.c.

References currticks(), execv(), parse_options(), printf(), rc, start, and TICKS_PER_SEC.

                                               {
        struct time_options opts;
        unsigned long start;
        unsigned long elapsed;
        int decisecs;
        int rc;

        /* Parse options */
        if ( ( rc = parse_options ( argc, argv, &time_cmd, &opts ) ) != 0 )
                return rc;

        start = currticks();
        rc = execv ( argv[1], argv + 1 );
        elapsed = ( currticks() - start );
        decisecs = ( 10 * elapsed / TICKS_PER_SEC );

        printf ( "%s: %d.%ds\n", argv[0],
                 ( decisecs / 10 ), ( decisecs % 10 ) );

        return rc;
}

Variable Documentation

struct option_descriptor time_opts[] = {} [static]

"time" option list

Definition at line 43 of file time_cmd.c.

struct command_descriptor time_cmd [static]
Initial value:
        COMMAND_DESC ( struct time_options, time_opts, 1, MAX_ARGUMENTS,
                       "<command>" )

"time" command descriptor

Definition at line 46 of file time_cmd.c.

struct command time_command __command
Initial value:
 {
        .name = "time",
        .exec = time_exec,
}

"time" command

Definition at line 80 of file time_cmd.c.