From 46433f9b5eb917e6ad90ffaa169febdfcf78270f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Jul 2013 15:30:00 +0100 Subject: [PATCH] [parseopt] Move parse_settings() to parseopt.c Signed-off-by: Michael Brown --- src/core/parseopt.c | 23 +++++++++++++++++++++++ src/hci/commands/config_cmd.c | 22 ---------------------- src/include/ipxe/parseopt.h | 3 ++- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/core/parseopt.c b/src/core/parseopt.c index 1ae5d9b2..15cca085 100644 --- a/src/core/parseopt.c +++ b/src/core/parseopt.c @@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include /** @file @@ -172,6 +173,28 @@ int parse_key ( char *text, unsigned int *key ) { return parse_integer ( text, key ); } +/** + * Parse settings block name + * + * @v text Text + * @ret value Integer value + * @ret rc Return status code + */ +int parse_settings ( char *text, struct settings **value ) { + + /* Sanity check */ + assert ( text != NULL ); + + /* Parse scope name */ + *value = find_settings ( text ); + if ( ! *value ) { + printf ( "\"%s\": no such scope\n", text ); + return -EINVAL; + } + + return 0; +} + /** * Print command usage message * diff --git a/src/hci/commands/config_cmd.c b/src/hci/commands/config_cmd.c index f1fb567c..b81c866f 100644 --- a/src/hci/commands/config_cmd.c +++ b/src/hci/commands/config_cmd.c @@ -44,28 +44,6 @@ static struct option_descriptor config_opts[] = {}; static struct command_descriptor config_cmd = COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[]" ); -/** - * Parse settings scope name - * - * @v text Text - * @ret value Integer value - * @ret rc Return status code - */ -static int parse_settings ( const char *text, struct settings **value ) { - - /* Sanity check */ - assert ( text != NULL ); - - /* Parse scope name */ - *value = find_settings ( text ); - if ( ! *value ) { - printf ( "\"%s\": no such scope\n", text ); - return -EINVAL; - } - - return 0; -} - /** * "config" command * diff --git a/src/include/ipxe/parseopt.h b/src/include/ipxe/parseopt.h index 1e1fe6b7..8aeed974 100644 --- a/src/include/ipxe/parseopt.h +++ b/src/include/ipxe/parseopt.h @@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct net_device; struct menu; +struct settings; /** A command-line option descriptor */ struct option_descriptor { @@ -120,7 +121,7 @@ extern int parse_netdev ( char *text, struct net_device **netdev ); extern int parse_menu ( char *text, struct menu **menu ); extern int parse_flag ( char *text __unused, int *flag ); extern int parse_key ( char *text, unsigned int *key ); -extern void print_usage ( struct command_descriptor *cmd, char **argv ); +extern int parse_settings ( char *text, struct settings **settings ); extern int reparse_options ( int argc, char **argv, struct command_descriptor *cmd, void *opts ); extern int parse_options ( int argc, char **argv,