dynamic-array: fix documentation of lttng_dynamic_pointer_array_get_pointer
[lttng-tools.git] / src / common / uuid.h
CommitLineData
ffe60014 1/*
c70636a7 2 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ffe60014
DG
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22
23#ifndef LTTNG_UUID_H
24#define LTTNG_UUID_H
25
bef4c7a1 26#include <common/macros.h>
8cfbd4f4 27#include <stdbool.h>
c70636a7
MJ
28#include <stdint.h>
29#include <inttypes.h>
bef4c7a1 30
ffe60014
DG
31/*
32 * Includes final \0.
33 */
c70636a7
MJ
34#define LTTNG_UUID_STR_LEN 37
35#define LTTNG_UUID_LEN 16
36#define LTTNG_UUID_VER 4
ffe60014 37
c70636a7
MJ
38#define LTTNG_UUID_FMT \
39 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
40 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
41 "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
42 "%02" SCNx8
52a0e931 43
c70636a7
MJ
44#define LTTNG_UUID_FMT_VALUES(uuid) \
45 (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
46 (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
47 (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
ffe60014 48
c70636a7
MJ
49#define LTTNG_UUID_SCAN_VALUES(uuid) \
50 &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
51 &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
52 &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
ffe60014 53
c70636a7 54typedef uint8_t lttng_uuid[LTTNG_UUID_LEN];
ffe60014 55
c70636a7
MJ
56LTTNG_HIDDEN
57int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
ffe60014 58
bef4c7a1
JG
59/*
60 * Convert a UUID to a human-readable, NULL-terminated, string of the form
61 * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
62 *
c70636a7 63 * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
bef4c7a1
JG
64 */
65LTTNG_HIDDEN
52a0e931 66void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str);
bef4c7a1 67
8cfbd4f4
JG
68LTTNG_HIDDEN
69bool lttng_uuid_is_equal(const lttng_uuid a, const lttng_uuid b);
70
4c97f6bd
JG
71LTTNG_HIDDEN
72bool lttng_uuid_is_nil(const lttng_uuid uuid);
73
eafef9eb
JG
74LTTNG_HIDDEN
75void lttng_uuid_copy(lttng_uuid dst, const lttng_uuid src);
76
c70636a7
MJ
77/*
78 * Generate a random UUID according to RFC4122, section 4.4.
79 */
80LTTNG_HIDDEN
81int lttng_uuid_generate(lttng_uuid uuid_out);
82
ffe60014 83#endif /* LTTNG_UUID_H */
This page took 0.063013 seconds and 5 git commands to generate.