2 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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
26 #include <common/macros.h>
34 #define LTTNG_UUID_STR_LEN 37
35 #define LTTNG_UUID_LEN 16
36 #define LTTNG_UUID_VER 4
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 \
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]
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]
54 typedef uint8_t lttng_uuid
[LTTNG_UUID_LEN
];
57 int lttng_uuid_from_str(const char *str_in
, lttng_uuid uuid_out
);
60 * Convert a UUID to a human-readable, NULL-terminated, string of the form
61 * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
63 * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
66 void lttng_uuid_to_str(const lttng_uuid uuid
, char *uuid_str
);
69 bool lttng_uuid_is_equal(const lttng_uuid a
, const lttng_uuid b
);
72 bool lttng_uuid_is_nil(const lttng_uuid uuid
);
75 void lttng_uuid_copy(lttng_uuid dst
, const lttng_uuid src
);
78 * Generate a random UUID according to RFC4122, section 4.4.
81 int lttng_uuid_generate(lttng_uuid uuid_out
);
83 #endif /* LTTNG_UUID_H */
This page took 0.032184 seconds and 5 git commands to generate.