summaryrefslogtreecommitdiffstats
path: root/src/core/parseopt.c
diff options
context:
space:
mode:
authorMichael Brown2024-02-29 15:05:39 +0100
committerMichael Brown2024-02-29 16:20:44 +0100
commit7cd73884e51f6d3649aa2ea0ed0cec0b39192f61 (patch)
tree8d63995a240fb0b99c7ddcf3e1a3ed6efa281a10 /src/core/parseopt.c
parent[settings] Add parsing for UUID and GUID settings types (diff)
downloadipxe-7cd73884e51f6d3649aa2ea0ed0cec0b39192f61.tar.gz
ipxe-7cd73884e51f6d3649aa2ea0ed0cec0b39192f61.tar.xz
ipxe-7cd73884e51f6d3649aa2ea0ed0cec0b39192f61.zip
[parseopt] Add parse_uuid() for parsing UUID command-line arguments
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/parseopt.c')
-rw-r--r--src/core/parseopt.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/parseopt.c b/src/core/parseopt.c
index cd3b3101..7aff1485 100644
--- a/src/core/parseopt.c
+++ b/src/core/parseopt.c
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
+#include <ipxe/uuid.h>
#include <ipxe/netdevice.h>
#include <ipxe/menu.h>
#include <ipxe/settings.h>
@@ -125,6 +126,28 @@ int parse_timeout ( char *text, unsigned long *value ) {
}
/**
+ * Parse UUID
+ *
+ * @v text Text
+ * @ret value UUID value
+ * @ret rc Return status code
+ */
+int parse_uuid ( char *text, union uuid *value ) {
+ int rc;
+
+ /* Sanity check */
+ assert ( text != NULL );
+
+ /* Parse UUID */
+ if ( ( rc = uuid_aton ( text, value ) ) != 0 ) {
+ printf ( "\"%s\": invalid UUID\n", text );
+ return rc;
+ }
+
+ return 0;
+}
+
+/**
* Parse network device name
*
* @v text Text