88787c5aee60ac21dee447e62661dee3d6023c20
[babeltrace.git] / src / common / uuid.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
5 */
6
7 #ifndef _BABELTRACE_COMMON_UUID_H
8 #define _BABELTRACE_COMMON_UUID_H
9
10 #include <stdint.h>
11 #include "common/macros.h"
12
13 #define BT_UUID_STR_LEN 36 /* Excludes final \0 */
14 #define BT_UUID_LEN 16
15 #define BT_UUID_VER 4
16
17 #define BT_UUID_FMT \
18 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
19 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
20 "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
21 "%02" SCNx8
22
23 #define BT_UUID_FMT_VALUES(uuid) \
24 (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
25 (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
26 (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
27
28 #define BT_UUID_SCAN_VALUES(uuid) \
29 &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
30 &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
31 &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
32
33 typedef uint8_t bt_uuid_t[BT_UUID_LEN];
34
35 BT_HIDDEN void bt_uuid_generate(bt_uuid_t uuid_out);
36 BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out);
37 BT_HIDDEN int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out);
38 BT_HIDDEN int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b);
39 BT_HIDDEN void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src);
40
41 #endif /* _BABELTRACE_COMMON_UUID_H */
This page took 0.02921 seconds and 4 git commands to generate.