mirror of
https://github.com/ipxe/ipxe
synced 2026-02-03 22:49:29 +03:00
[uuid] Add uuid_aton() to parse a UUID from a string
Add uuid_aton() to parse a UUID value from a string (analogous to inet_aton(), inet6_aton(), sock_aton(), etc), treating it as a 32-digit hex string with optional hyphen separators. The placement of the separators is not checked: each byte within the hex string may be separated by a hyphen, or not separated at all. Add dedicated self-tests for UUID parsing and formatting (already partially covered by the ":uuid" and ":guid" settings self-tests). Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -12,6 +12,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/** Treat separator as optional while decoding */
|
||||
#define HEX_DECODE_OPTIONAL 0x80
|
||||
|
||||
/**
|
||||
* Calculate length of base16-encoded data
|
||||
*
|
||||
|
||||
@@ -79,6 +79,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define ERRFILE_cachedhcp ( ERRFILE_CORE | 0x00270000 )
|
||||
#define ERRFILE_acpimac ( ERRFILE_CORE | 0x00280000 )
|
||||
#define ERRFILE_efi_strings ( ERRFILE_CORE | 0x00290000 )
|
||||
#define ERRFILE_uuid ( ERRFILE_CORE | 0x002a0000 )
|
||||
|
||||
#define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 )
|
||||
#define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 )
|
||||
|
||||
@@ -48,5 +48,6 @@ static inline void uuid_mangle ( union uuid *uuid ) {
|
||||
}
|
||||
|
||||
extern const char * uuid_ntoa ( const union uuid *uuid );
|
||||
extern int uuid_aton ( const char *string, union uuid *uuid );
|
||||
|
||||
#endif /* _IPXE_UUID_H */
|
||||
|
||||
Reference in New Issue
Block a user