]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-id128/id128-util.h
Merge pull request #18863 from keszybz/cmdline-escaping
[thirdparty/systemd.git] / src / libsystemd / sd-id128 / id128-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "sd-id128.h"
7
8 #include "hash-funcs.h"
9 #include "macro.h"
10
11 #define ID128_UUID_STRING_MAX 37
12
13 char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]);
14
15 bool id128_is_valid(const char *s) _pure_;
16
17 typedef enum Id128Format {
18 ID128_ANY,
19 ID128_PLAIN, /* formatted as 32 hex chars as-is */
20 ID128_PLAIN_OR_UNINIT, /* formatted as 32 hex chars as-is; allow special "uninitialized"
21 * value when reading from file (id128_read() and id128_read_fd()).
22 *
23 * This format should be used when reading a machine-id file. */
24 ID128_UUID, /* formatted as 36 character uuid string */
25 _ID128_FORMAT_MAX,
26 } Id128Format;
27
28 int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret);
29 int id128_read(const char *p, Id128Format f, sd_id128_t *ret);
30
31 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync);
32 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync);
33
34 void id128_hash_func(const sd_id128_t *p, struct siphash *state);
35 int id128_compare_func(const sd_id128_t *a, const sd_id128_t *b) _pure_;
36 extern const struct hash_ops id128_hash_ops;
37
38 sd_id128_t id128_make_v4_uuid(sd_id128_t id);
39
40 int id128_get_product(sd_id128_t *ret);