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)
 
static int poweroff_exec (int argc, char **argv)
 The "poweroff" command. More...
 

Variables

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

Detailed Description

Power off command.

Definition in file poweroff_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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 56 of file poweroff_cmd.c.

56  {
57  struct poweroff_options opts;
58  int rc;
59 
60  /* Parse options */
61  if ( ( rc = parse_options ( argc, argv, &poweroff_cmd, &opts ) ) != 0 )
62  return rc;
63 
64  /* Power off system */
65  rc = poweroff();
66  if ( rc != 0 )
67  printf ( "Could not power off: %s\n", strerror ( rc ) );
68 
69  return rc;
70 }
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:464
"poweroff" options
Definition: poweroff_cmd.c:40
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
int poweroff(void)
Power off system.
static union @423 opts
"cert<xxx>" option list
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static struct command_descriptor poweroff_cmd
"poweroff" command descriptor
Definition: poweroff_cmd.c:46

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

Variable Documentation

◆ poweroff_opts

struct option_descriptor poweroff_opts[] = {}
static

"poweroff" option list

Definition at line 43 of file poweroff_cmd.c.

◆ poweroff_cmd

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

"poweroff" command descriptor

Definition at line 46 of file poweroff_cmd.c.

Referenced by poweroff_exec().

◆ __command

struct command poweroff_command __command
Initial value:
= {
.name = "poweroff",
.exec = poweroff_exec,
}
static int poweroff_exec(int argc, char **argv)
The "poweroff" command.
Definition: poweroff_cmd.c:56

"poweroff" command

Definition at line 73 of file poweroff_cmd.c.