blob: eb1d41ecb58c01882c8e6006cad906ca2b4f3c96 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#ifndef L2SU_UUID_H_INCLUDED
#define L2SU_UUID_H_INCLUDED
#include <stdint.h>
#include <stdbool.h>
/* A 128-bit GUID as specified by RFC 4122.
* NOTE: halves[0] is the least significant half of the GUID. */
typedef union tag_uuid_t {
uint8_t bytes[16];
uint64_t halves[2];
#define uuid_ls halves[0]
#define uuid_ms halves[1]
} uuid_t;
#define UUID_NULL_INIT { { 0 } }
#define UUID_STRLEN (36u)
#define UUID_STRLEN_SHORT (32u)
void l2_uuid_random(uuid_t *id);
void l2_uuid_to_string(const uuid_t *id, char *out);
void l2_uuid_to_string_short(const uuid_t *id, char *out);
bool l2_uuid_from_string(uuid_t *id, const char *str);
bool l2_uuid_from_string_short(uuid_t *id, const char *str);
int l2_uuid_compare(const uuid_t *c1, const uuid_t *c2);
void l2_uuid_copy(uuid_t *restrict dest, const uuid_t *restrict src);
#endif /* include guard */
|