From 2e6a0f805298f943cdfa77be5bbeadc2bbf0006f Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 24 Oct 2019 15:01:33 +0200 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/36297 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/include/uuid.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/include') 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 +#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; -- cgit v1.2.3