Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/runtime/uuid.h

raw
1 /*
2 * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2024 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 11 мая 2024 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_RUNTIME_UUID_H_
23 #define LSP_PLUG_IN_RUNTIME_UUID_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26
27 #include <lsp-plug.in/common/types.h>
28
29 namespace lsp
30 {
31 typedef struct uuid_t
32 {
33 union {
34 uint8_t u8[16];
35 uint16_t u16[8];
36 uint32_t u32[4];
37 uint64_t u64[2];
38 };
39 } uuid_t;
40
41 /**
42 * Generate UUID
43 * @param uuid UUID to generate
44 */
45 void generate_uuid(uuid_t *uuid);
46
47 /**
48 * Format UUID (plain hex values without dashes)
49 * @param dst buffer to store UUID (should be at least 33 characters long)
50 * @param upper use upper case for hex digits
51 * @param uuid UUID to format
52 * @return ponter to the zero-terminating character stored to buffer
53 */
54 char *format_uuid_hex(char *dst, const uuid_t *uuid, bool upper = false);
55
56 /**
57 * Format UUID (plain hex values with dashes)
58 * @param dst buffer to store UUID (should be at least 37 characters long)
59 * @param upper use upper case for hex digits
60 * @param uuid UUID to format
61 * @return ponter to the zero-terminating character stored to buffer
62 */
63 char *format_uuid_dashed(char *dst, const uuid_t *uuid, bool upper = false);
64
65 /**
66 * Format UID (plain text values without dashes), non-standard Base64 table is used because
67 * standard Base64 table allows to use file separator characters
68 * @param dst buffer to store UUID (should be at least 23 characters long)
69 * @return ponter to the zero-terminating character stored to buffer
70 */
71 char *format_uuid_base64(char *dst, const uuid_t *uuid);
72
73 } /* namespace lsp */
74
75 #endif /* LSP_PLUG_IN_RUNTIME_UUID_H_ */