2006-12-04 23:40:35 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
2007-01-19 01:13:12 +00:00
|
|
|
#include <stdio.h>
|
2006-12-04 23:40:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
2006-12-08 01:26:11 +00:00
|
|
|
#include <getopt.h>
|
2010-04-19 20:16:01 +01:00
|
|
|
#include <ipxe/settings.h>
|
|
|
|
|
#include <ipxe/command.h>
|
2006-12-04 23:40:35 +00:00
|
|
|
|
2009-05-01 15:41:06 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
|
|
|
|
2006-12-04 23:40:35 +00:00
|
|
|
static int show_exec ( int argc, char **argv ) {
|
2006-12-05 02:40:03 +00:00
|
|
|
char buf[256];
|
|
|
|
|
int rc;
|
2006-12-04 23:40:35 +00:00
|
|
|
|
2006-12-05 02:40:03 +00:00
|
|
|
if ( argc != 2 ) {
|
|
|
|
|
printf ( "Syntax: %s <identifier>\n", argv[0] );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-25 20:46:16 +00:00
|
|
|
if ( ( rc = fetchf_named_setting ( argv[1], buf,
|
|
|
|
|
sizeof ( buf ) ) ) < 0 ){
|
2006-12-05 02:40:03 +00:00
|
|
|
printf ( "Could not find \"%s\": %s\n",
|
2008-03-20 04:06:07 +00:00
|
|
|
argv[1], strerror ( rc ) );
|
2006-12-05 02:40:03 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf ( "%s = %s\n", argv[1], buf );
|
|
|
|
|
return 0;
|
2006-12-04 23:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int set_exec ( int argc, char **argv ) {
|
2006-12-05 02:40:03 +00:00
|
|
|
int rc;
|
2006-12-04 23:40:35 +00:00
|
|
|
|
|
|
|
|
if ( argc != 3 ) {
|
2008-03-20 04:06:07 +00:00
|
|
|
printf ( "Syntax: %s <identifier> <value>\n", argv[0] );
|
2006-12-04 23:40:35 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-25 20:46:16 +00:00
|
|
|
if ( ( rc = storef_named_setting ( argv[1], argv[2] ) ) != 0 ) {
|
2006-12-05 02:40:03 +00:00
|
|
|
printf ( "Could not set \"%s\"=\"%s\": %s\n",
|
2008-03-20 04:06:07 +00:00
|
|
|
argv[1], argv[2], strerror ( rc ) );
|
2006-12-04 23:40:35 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-12 15:52:19 +00:00
|
|
|
static int clear_exec ( int argc, char **argv ) {
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
if ( argc != 2 ) {
|
2008-03-20 04:06:07 +00:00
|
|
|
printf ( "Syntax: %s <identifier>\n", argv[0] );
|
2006-12-12 15:52:19 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-20 04:06:07 +00:00
|
|
|
if ( ( rc = delete_named_setting ( argv[1] ) ) != 0 ) {
|
2006-12-12 15:52:19 +00:00
|
|
|
printf ( "Could not clear \"%s\": %s\n",
|
2008-03-20 04:06:07 +00:00
|
|
|
argv[1], strerror ( rc ) );
|
2006-12-12 15:52:19 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-10 05:13:20 +00:00
|
|
|
struct command nvo_commands[] __command = {
|
|
|
|
|
{
|
|
|
|
|
.name = "show",
|
|
|
|
|
.exec = show_exec,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.name = "set",
|
|
|
|
|
.exec = set_exec,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.name = "clear",
|
|
|
|
|
.exec = clear_exec,
|
|
|
|
|
},
|
2006-12-12 15:52:19 +00:00
|
|
|
};
|