| 1 |
|
| 2 |
|
| 3 |
#ifndef _UUID_H_ |
| 4 |
#define _UUID_H_ |
| 5 |
|
| 6 |
#include <string.h> |
| 7 |
#include <stdint.h> |
| 8 |
|
| 9 |
#define UUID_LEN 16 |
| 10 |
#define UUID_STRLEN 36 |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
int parse_uuid(uint8_t *uuid, const char *uuid_str); |
| 24 |
|
| 25 |
typedef struct { |
| 26 |
uint8_t b[16]; |
| 27 |
} __packed guid_t; |
| 28 |
|
| 29 |
#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ |
| 30 |
((guid_t) \ |
| 31 |
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ |
| 32 |
(b) & 0xff, ((b) >> 8) & 0xff, \ |
| 33 |
(c) & 0xff, ((c) >> 8) & 0xff, \ |
| 34 |
(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }) |
| 35 |
|
| 36 |
static inline int guidcmp(const guid_t *guid1, const guid_t *guid2) |
| 37 |
{ |
| 38 |
return memcmp(guid1, guid2, sizeof(guid_t)); |
| 39 |
} |
| 40 |
|
| 41 |
static inline guid_t *guidcpy(guid_t *dest, const guid_t *src) |
| 42 |
{ |
| 43 |
return (guid_t *)memcpy(dest, src, sizeof(guid_t)); |
| 44 |
} |
| 45 |
|
| 46 |
#endif |