[prefix] Remove unsupported .exe prefix
[gpxe.git] / src / hci / commands / nvo_cmd.c
blob5eb2f06f55127d1460d1dbcf6aa25c53bc4ad04f
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <errno.h>
6 #include <getopt.h>
7 #include <gpxe/settings.h>
8 #include <gpxe/command.h>
10 FILE_LICENCE ( GPL2_OR_LATER );
12 static int show_exec ( int argc, char **argv ) {
13 char buf[256];
14 int rc;
16 if ( argc != 2 ) {
17 printf ( "Syntax: %s <identifier>\n", argv[0] );
18 return 1;
21 if ( ( rc = fetchf_named_setting ( argv[1], buf,
22 sizeof ( buf ) ) ) < 0 ){
23 printf ( "Could not find \"%s\": %s\n",
24 argv[1], strerror ( rc ) );
25 return 1;
28 printf ( "%s = %s\n", argv[1], buf );
29 return 0;
32 static int set_exec ( int argc, char **argv ) {
33 int rc;
35 if ( argc != 3 ) {
36 printf ( "Syntax: %s <identifier> <value>\n", argv[0] );
37 return 1;
40 if ( ( rc = storef_named_setting ( argv[1], argv[2] ) ) != 0 ) {
41 printf ( "Could not set \"%s\"=\"%s\": %s\n",
42 argv[1], argv[2], strerror ( rc ) );
43 return 1;
46 return 0;
49 static int clear_exec ( int argc, char **argv ) {
50 int rc;
52 if ( argc != 2 ) {
53 printf ( "Syntax: %s <identifier>\n", argv[0] );
54 return 1;
57 if ( ( rc = delete_named_setting ( argv[1] ) ) != 0 ) {
58 printf ( "Could not clear \"%s\": %s\n",
59 argv[1], strerror ( rc ) );
60 return 1;
63 return 0;
66 struct command nvo_commands[] __command = {
68 .name = "show",
69 .exec = show_exec,
72 .name = "set",
73 .exec = set_exec,
74 },
76 .name = "clear",
77 .exec = clear_exec,