summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2019-10-24 15:01:33 +0200
committerPatrick Georgi <pgeorgi@google.com>2019-11-01 11:38:22 +0000
commit2e6a0f805298f943cdfa77be5bbeadc2bbf0006f (patch)
treee3e9a9e98f8fb94a883f17e0c0f596250170c879 /src/include
parentf71bb5d1746c8cabc2fbd79420c3bcfc439ad41b (diff)
downloadcoreboot-2e6a0f805298f943cdfa77be5bbeadc2bbf0006f.tar.xz
lib/uuid: Add UUID parsing function
Implement a simple function that parses a canonical UUID string into the common byte representation. Inspired by acpigen_write_uuid(). Change-Id: Ia1bd883c740873699814fde6c6ddc1937a40093e Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/36297 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/uuid.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/include/uuid.h b/src/include/uuid.h
index 0209055e9e..b8827b0510 100644
--- a/src/include/uuid.h
+++ b/src/include/uuid.h
@@ -18,6 +18,22 @@
#include <string.h>
+#define UUID_LEN 16
+#define UUID_STRLEN 36
+
+/*
+ * Parses a canonical UUID string into the common byte representation
+ * where the first three words are interpreted as little endian:
+ *
+ * The UUID
+ * "00112233-4455-6677-8899-aabbccddeeff"
+ * is stored as
+ * 33 22 11 00 55 44 77 66 88 99 aa bb cc dd ee ff
+ *
+ * Returns negative value on error, 0 on success.
+ */
+int parse_uuid(uint8_t *uuid, const char *uuid_str);
+
typedef struct {
uint8_t b[16];
} __packed guid_t;