summaryrefslogtreecommitdiffstats
path: root/src/hci
diff options
context:
space:
mode:
authorMichael Brown2010-11-21 20:58:45 +0100
committerMichael Brown2010-11-22 01:34:48 +0100
commit46116d8d03ea3df73a93c386c2be33fc8be9cde0 (patch)
treeb538826c9a36986c0e57b4ae2f51bf0d68cea072 /src/hci
parent[san] Use generic option-parsing library (diff)
downloadipxe-46116d8d03ea3df73a93c386c2be33fc8be9cde0.tar.gz
ipxe-46116d8d03ea3df73a93c386c2be33fc8be9cde0.tar.xz
ipxe-46116d8d03ea3df73a93c386c2be33fc8be9cde0.zip
[route] Use generic option-parsing library
Total saving: 71 bytes. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r--src/hci/commands/route_cmd.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/src/hci/commands/route_cmd.c b/src/hci/commands/route_cmd.c
index 057349723..a4f5f91d3 100644
--- a/src/hci/commands/route_cmd.c
+++ b/src/hci/commands/route_cmd.c
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdio.h>
#include <getopt.h>
#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
#include <usr/route.h>
/** @file
@@ -29,52 +30,34 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
*/
-/**
- * "route" command syntax message
- *
- * @v argv Argument list
- */
-static void route_syntax ( char **argv ) {
- printf ( "Usage:\n"
- " %s\n"
- "\n"
- "Displays the routing table\n",
- argv[0] );
-}
+/** "route" options */
+struct route_options {};
+
+/** "route" option list */
+static struct option_descriptor route_opts[] = {};
+
+/** "route" command descriptor */
+static struct command_descriptor route_cmd =
+ COMMAND_DESC ( struct route_options, route_opts, 0, 0,
+ "", "Display the routing table" );
/**
* The "route" command
*
* @v argc Argument count
* @v argv Argument list
- * @ret rc Exit code
+ * @ret rc Return status code
*/
static int route_exec ( int argc, char **argv ) {
- static struct option longopts[] = {
- { "help", 0, NULL, 'h' },
- { NULL, 0, NULL, 0 },
- };
-
- int c;
+ struct route_options opts;
+ int rc;
/* Parse options */
- while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
- switch ( c ) {
- case 'h':
- /* Display help text */
- default:
- /* Unrecognised/invalid option */
- route_syntax ( argv );
- return 1;
- }
- }
-
- if ( optind != argc ) {
- route_syntax ( argv );
- return 1;
- }
+ if ( ( rc = parse_options ( argc, argv, &route_cmd, &opts ) ) != 0 )
+ return rc;
route();
+
return 0;
}