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>
This commit is contained in:
Nico Huber
2019-10-24 15:01:33 +02:00
committed by Patrick Georgi
parent f71bb5d174
commit 2e6a0f8052
3 changed files with 53 additions and 0 deletions

View File

@@ -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;