mirror of
https://github.com/ipxe/ipxe
synced 2025-12-20 20:10:18 +03:00
[parseopt] Allow "prompt" command to accept character literals for --key
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -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
|
||||
@@ -129,6 +128,25 @@ int parse_flag ( const char *text __unused, int *flag ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user