From a1685cb3e2ef4c3a808496576dfca0e216258566 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Dec 2006 00:31:34 +0000 Subject: Move nvo_cmd.c to hci/commands. --- src/Makefile | 4 +- src/commandline/commands/nvo_cmd.c | 111 ------------------------------------- src/hci/commands/nvo_cmd.c | 111 +++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 114 deletions(-) delete mode 100644 src/commandline/commands/nvo_cmd.c create mode 100644 src/hci/commands/nvo_cmd.c (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 09bede176..fae083fff 100644 --- a/src/Makefile +++ b/src/Makefile @@ -144,9 +144,7 @@ SRCDIRS += drivers/bitbash SRCDIRS += interface/pxe SRCDIRS += tests SRCDIRS += crypto -SRCDIRS += hci hci/mucurses -SRCDIRS += commandline -SRCDIRS += commandline/commands +SRCDIRS += hci hci/commands hci/mucurses # NON_AUTO_SRCS lists files that are excluded from the normal # automatic build system. diff --git a/src/commandline/commands/nvo_cmd.c b/src/commandline/commands/nvo_cmd.c deleted file mode 100644 index 0ea7d8624..000000000 --- a/src/commandline/commands/nvo_cmd.c +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void nvo_cmd_req() {} - -extern struct nvo_block *ugly_nvo_hack; - -static int show_exec ( int argc, char **argv ) { - struct config_context dummy_context; - char buf[256]; - int rc; - - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - - if ( argc != 2 ) { - printf ( "Syntax: %s \n", argv[0] ); - return 1; - } - - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = show_setting ( &dummy_context, argv[1], buf, - sizeof ( buf ) ) ) != 0 ) { - printf ( "Could not find \"%s\": %s\n", - argv[1], strerror ( -rc ) ); - return 1; - } - - printf ( "%s = %s\n", argv[1], buf ); - return 0; -} - -struct command show_command __command = { - .name = "show", - .exec = show_exec, -}; - -static int set_exec ( int argc, char **argv ) { - struct config_context dummy_context; - int rc; - - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - - if ( argc != 3 ) { - printf ( "Syntax: %s \n", - argv[0] ); - return 1; - } - - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = set_setting ( &dummy_context, argv[1], argv[2] ) ) != 0 ) { - printf ( "Could not set \"%s\"=\"%s\": %s\n", - argv[1], argv[2], strerror ( -rc ) ); - return 1; - } - - if ( nvo_save ( ugly_nvo_hack ) != 0 ) { - printf ( "Could not save options to non-volatile storage\n" ); - return 1; - } - - return 0; -} - -struct command set_command __command = { - .name = "set", - .exec = set_exec, -}; - -static int clear_exec ( int argc, char **argv ) { - struct config_context dummy_context; - int rc; - - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - - if ( argc != 2 ) { - printf ( "Syntax: %s \n", - argv[0] ); - return 1; - } - - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = clear_setting ( &dummy_context, argv[1] ) ) != 0 ) { - printf ( "Could not clear \"%s\": %s\n", - argv[1], strerror ( -rc ) ); - return 1; - } - - return 0; -} - -struct command clear_command __command = { - .name = "clear", - .exec = clear_exec, -}; diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c new file mode 100644 index 000000000..0ea7d8624 --- /dev/null +++ b/src/hci/commands/nvo_cmd.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void nvo_cmd_req() {} + +extern struct nvo_block *ugly_nvo_hack; + +static int show_exec ( int argc, char **argv ) { + struct config_context dummy_context; + char buf[256]; + int rc; + + if ( ! ugly_nvo_hack ) { + printf ( "No non-volatile option storage available\n" ); + return 1; + } + + if ( argc != 2 ) { + printf ( "Syntax: %s \n", argv[0] ); + return 1; + } + + dummy_context.options = ugly_nvo_hack->options; + if ( ( rc = show_setting ( &dummy_context, argv[1], buf, + sizeof ( buf ) ) ) != 0 ) { + printf ( "Could not find \"%s\": %s\n", + argv[1], strerror ( -rc ) ); + return 1; + } + + printf ( "%s = %s\n", argv[1], buf ); + return 0; +} + +struct command show_command __command = { + .name = "show", + .exec = show_exec, +}; + +static int set_exec ( int argc, char **argv ) { + struct config_context dummy_context; + int rc; + + if ( ! ugly_nvo_hack ) { + printf ( "No non-volatile option storage available\n" ); + return 1; + } + + if ( argc != 3 ) { + printf ( "Syntax: %s \n", + argv[0] ); + return 1; + } + + dummy_context.options = ugly_nvo_hack->options; + if ( ( rc = set_setting ( &dummy_context, argv[1], argv[2] ) ) != 0 ) { + printf ( "Could not set \"%s\"=\"%s\": %s\n", + argv[1], argv[2], strerror ( -rc ) ); + return 1; + } + + if ( nvo_save ( ugly_nvo_hack ) != 0 ) { + printf ( "Could not save options to non-volatile storage\n" ); + return 1; + } + + return 0; +} + +struct command set_command __command = { + .name = "set", + .exec = set_exec, +}; + +static int clear_exec ( int argc, char **argv ) { + struct config_context dummy_context; + int rc; + + if ( ! ugly_nvo_hack ) { + printf ( "No non-volatile option storage available\n" ); + return 1; + } + + if ( argc != 2 ) { + printf ( "Syntax: %s \n", + argv[0] ); + return 1; + } + + dummy_context.options = ugly_nvo_hack->options; + if ( ( rc = clear_setting ( &dummy_context, argv[1] ) ) != 0 ) { + printf ( "Could not clear \"%s\": %s\n", + argv[1], strerror ( -rc ) ); + return 1; + } + + return 0; +} + +struct command clear_command __command = { + .name = "clear", + .exec = clear_exec, +}; -- cgit v1.2.3-55-g7522