blob: dda824160c2bcf7b0d95b968522a0788d08a7831 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __UUID_UTILS_H__
8#define __UUID_UTILS_H__
9
10#include <stdint.h>
11#include <uuid.h>
12
13/* Size (in bytes) of a UUID string as formatted by uuid_to_str() */
14#define UUID_STR_SIZE 79
15
16/*
17 * Convert a UUID into a string.
18 *
19 * The caller is responsible for allocating the output string buffer
20 * pointed by 'str'. It must be at least UUID_STR_SIZE bytes long.
21 *
22 * Return the UUID string.
23 */
24char *uuid_to_str(const uuid_t *uuid, char *str);
25
26/*
27 * Return 1 if uuid == uuid_null, 0 otherwise.
28 */
29unsigned int is_uuid_null(const uuid_t *uuid);
30
31/*
32 * Return 1 if uuid1 == uuid2, 0 otherwise.
33 */
34unsigned int uuid_equal(const uuid_t *uuid1, const uuid_t *uuid2);
35
36/*
37 * Take four 32-bit words of data and combine them into a UUID.
38 *
39 * The caller is responsible for allocating the output UUID variable
40 * pointed by 'uuid'.
41 *
42 * Return the UUID.
43 */
44uuid_t *make_uuid_from_4words(uuid_t *uuid,
45 uint32_t uuid0,
46 uint32_t uuid1,
47 uint32_t uuid2,
48 uint32_t uuid3);
49
50#endif /* __UUID_UTILS_H__ */