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

Form parameter commands. More...

#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <ipxe/params.h>
#include <ipxe/parseopt.h>
#include <ipxe/command.h>

Go to the source code of this file.

Data Structures

struct  params_options
 "params" options More...
 
struct  param_options
 "param" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int params_exec (int argc, char **argv)
 The "params" command. More...
 
static int param_exec (int argc, char **argv)
 The "param" command. More...
 

Variables

static struct option_descriptor params_opts []
 "params" option list More...
 
static struct command_descriptor params_cmd
 "params" command descriptor More...
 
static struct option_descriptor param_opts []
 "param" option list More...
 
static struct command_descriptor param_cmd
 "param" command descriptor More...
 
struct command param_commands [] __command
 Form parameter commands. More...
 

Detailed Description

Form parameter commands.

Definition in file param_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ params_exec()

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

The "params" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 66 of file param_cmd.c.

66  {
67  struct params_options opts;
68  struct parameters *params;
69  int rc;
70 
71  /* Parse options */
72  if ( ( rc = parse_options ( argc, argv, &params_cmd, &opts ) ) != 0)
73  return rc;
74 
75  /* Create parameter list */
76  params = create_parameters ( opts.name );
77  if ( ! params )
78  return -ENOMEM;
79 
80  /* Destroy parameter list, if applicable */
81  if ( opts.delete ) {
82  claim_parameters ( params );
83  params_put ( params );
84  }
85 
86  return 0;
87 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A form parameter list.
Definition: params.h:16
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
#define ENOMEM
Not enough space.
Definition: errno.h:534
"params" options
Definition: param_cmd.c:40
struct parameters * create_parameters(const char *name)
Create form parameter list.
Definition: params.c:86
static union @423 opts
"cert<xxx>" option list
static struct command_descriptor params_cmd
"params" command descriptor
Definition: param_cmd.c:56

References create_parameters(), ENOMEM, opts, params_cmd, parse_options(), and rc.

◆ param_exec()

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

The "param" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 113 of file param_cmd.c.

113  {
114  struct param_options opts;
115  char *key;
116  char *value;
117  struct parameters *params;
118  struct parameter *param;
119  int rc;
120 
121  /* Parse options */
122  if ( ( rc = parse_options ( argc, argv, &param_cmd, &opts ) ) != 0 )
123  goto err_parse_options;
124 
125  /* Parse key */
126  key = argv[optind];
127 
128  /* Parse value */
129  value = concat_args ( &argv[ optind + 1 ] );
130  if ( ! value ) {
131  rc = -ENOMEM;
132  goto err_parse_value;
133  }
134 
135  /* Identify parameter list */
136  if ( ( rc = parse_parameters ( opts.params, &params ) ) != 0 )
137  goto err_parse_parameters;
138 
139  /* Add parameter */
140  param = add_parameter ( params, key, value );
141  if ( ! param ) {
142  rc = -ENOMEM;
143  goto err_add_parameter;
144  }
145 
146  /* Success */
147  rc = 0;
148 
149  err_add_parameter:
150  err_parse_parameters:
151  free ( value );
152  err_parse_value:
153  err_parse_options:
154  return rc;
155 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
A form parameter list.
Definition: params.h:16
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value)
Add form parameter.
Definition: params.c:128
char * concat_args(char **args)
Concatenate arguments.
Definition: exec.c:358
"param" options
Definition: param_cmd.c:90
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static union @423 opts
"cert<xxx>" option list
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
int parse_parameters(char *text, struct parameters **params)
Parse form parameter list name.
Definition: parseopt.c:311
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
static struct command_descriptor param_cmd
"param" command descriptor
Definition: param_cmd.c:102
A form parameter.
Definition: params.h:28
union @375 key
Sense key.
Definition: scsi.h:18

References add_parameter(), concat_args(), ENOMEM, free, key, optind, opts, param, param_cmd, parse_options(), parse_parameters(), rc, and value.

Variable Documentation

◆ params_opts

struct option_descriptor params_opts[]
static
Initial value:
= {
OPTION_DESC ( "delete", 'd', no_argument,
struct params_options, delete, parse_flag ),
}
const char * name
Definition: ath9k_hw.c:1984
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:70
"params" options
Definition: param_cmd.c:40
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:200
Option does not take an argument.
Definition: getopt.h:16
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:66
Option requires an argument.
Definition: getopt.h:18

"params" option list

Definition at line 48 of file param_cmd.c.

◆ params_cmd

struct command_descriptor params_cmd
static
Initial value:
=
static struct option_descriptor params_opts[]
"params" option list
Definition: param_cmd.c:48
"params" options
Definition: param_cmd.c:40
#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

"params" command descriptor

Definition at line 56 of file param_cmd.c.

Referenced by params_exec().

◆ param_opts

struct option_descriptor param_opts[]
static
Initial value:
= {
OPTION_DESC ( "params", 'p', required_argument,
struct param_options, params, parse_string ),
}
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:70
"param" options
Definition: param_cmd.c:90
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:66
Option requires an argument.
Definition: getopt.h:18

"param" option list

Definition at line 96 of file param_cmd.c.

◆ param_cmd

struct command_descriptor param_cmd
static
Initial value:
=
"<key> [<value>]" )
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:96
"param" options
Definition: param_cmd.c:90
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
static struct option_descriptor param_opts[]
"param" option list
Definition: param_cmd.c:96

"param" command descriptor

Definition at line 102 of file param_cmd.c.

Referenced by param_exec().

◆ __command

struct command param_commands [] __command
Initial value:
= {
{
.name = "params",
.exec = params_exec,
},
{
.name = "param",
.exec = param_exec,
},
}
static int param_exec(int argc, char **argv)
The "param" command.
Definition: param_cmd.c:113
static int params_exec(int argc, char **argv)
The "params" command.
Definition: param_cmd.c:66

Form parameter commands.

Definition at line 158 of file param_cmd.c.