summaryrefslogtreecommitdiffstats
path: root/src/core/parseopt.c
diff options
context:
space:
mode:
authorMichael Brown2012-03-27 20:49:12 +0200
committerMichael Brown2012-03-29 01:21:19 +0200
commit0b1fe005b36ebc3af8de0d736e4a1227ba4580f8 (patch)
tree1e20637fc73d82834b9fb0729371dfeee81adb32 /src/core/parseopt.c
parent[readline] Accept Ctrl-U for "delete to start of line" (diff)
downloadipxe-0b1fe005b36ebc3af8de0d736e4a1227ba4580f8.tar.gz
ipxe-0b1fe005b36ebc3af8de0d736e4a1227ba4580f8.tar.xz
ipxe-0b1fe005b36ebc3af8de0d736e4a1227ba4580f8.zip
[parseopt] Allow "prompt" command to accept character literals for --key
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/parseopt.c')
-rw-r--r--src/core/parseopt.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/core/parseopt.c b/src/core/parseopt.c
index 2739bd87..57140690 100644
--- a/src/core/parseopt.c
+++ b/src/core/parseopt.c
@@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <errno.h>
#include <getopt.h>
#include <ipxe/netdevice.h>
-#include <ipxe/image.h>
#include <ipxe/parseopt.h>
/** @file
@@ -130,6 +129,25 @@ int parse_flag ( const char *text __unused, int *flag ) {
}
/**
+ * Parse key
+ *
+ * @v text Text
+ * @ret key Key
+ * @ret rc Return status code
+ */
+int parse_key ( const char *text, unsigned int *key ) {
+
+ /* Interpret single characters as being a literal key character */
+ if ( text[0] && ! text[1] ) {
+ *key = text[0];
+ return 0;
+ }
+
+ /* Otherwise, interpret as an integer */
+ return parse_integer ( text, key );
+}
+
+/**
* Print command usage message
*
* @v cmd Command descriptor