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

Power off command. More...

#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/reboot.h>

Go to the source code of this file.

Data Structures

struct  poweroff_options
 "poweroff" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static int poweroff_exec (int argc, char **argv)
 The "poweroff" command. More...
 
 COMMAND (poweroff, poweroff_exec)
 "poweroff" command More...
 

Variables

static struct option_descriptor poweroff_opts [] = {}
 "poweroff" option list More...
 
static struct command_descriptor poweroff_cmd
 "poweroff" command descriptor More...
 

Detailed Description

Power off command.

Definition in file poweroff_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ poweroff_exec()

static int poweroff_exec ( int  argc,
char **  argv 
)
static

The "poweroff" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 57 of file poweroff_cmd.c.

57  {
58  struct poweroff_options opts;
59  int rc;
60 
61  /* Parse options */
62  if ( ( rc = parse_options ( argc, argv, &poweroff_cmd, &opts ) ) != 0 )
63  return rc;
64 
65  /* Power off system */
66  rc = poweroff();
67  if ( rc != 0 )
68  printf ( "Could not power off: %s\n", strerror ( rc ) );
69 
70  return rc;
71 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
"poweroff" options
Definition: poweroff_cmd.c:41
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:485
int poweroff(void)
Power off system.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static struct command_descriptor poweroff_cmd
"poweroff" command descriptor
Definition: poweroff_cmd.c:47
static union @447 opts
"cert<xxx>" option list

References opts, parse_options(), poweroff(), poweroff_cmd, printf(), rc, and strerror().

◆ COMMAND()

COMMAND ( poweroff  ,
poweroff_exec   
)

"poweroff" command

Variable Documentation

◆ poweroff_opts

struct option_descriptor poweroff_opts[] = {}
static

"poweroff" option list

Definition at line 44 of file poweroff_cmd.c.

◆ poweroff_cmd

struct command_descriptor poweroff_cmd
static
Initial value:
=
"poweroff" options
Definition: poweroff_cmd.c:41
static struct option_descriptor poweroff_opts[]
"poweroff" option list
Definition: poweroff_cmd.c:44
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

"poweroff" command descriptor

Definition at line 47 of file poweroff_cmd.c.

Referenced by poweroff_exec().