]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-id128/id128-util.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / libsystemd / sd-id128 / id128-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
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 char *id128_to_uuid_string(sd_id128_t id, char s[37]);
12
13 /* Like SD_ID128_FORMAT_STR, but formats as UUID, not in plain format */
14 #define ID128_UUID_FORMAT_STR "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
15
16 bool id128_is_valid(const char *s) _pure_;
17
18 typedef enum Id128Format {
19 ID128_ANY,
20 ID128_PLAIN, /* formatted as 32 hex chars as-is */
21 ID128_UUID, /* formatted as 36 character uuid string */
22 _ID128_FORMAT_MAX,
23 } Id128Format;
24
25 int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret);
26 int id128_read(const char *p, Id128Format f, sd_id128_t *ret);
27
28 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync);
29 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync);
30
31 void id128_hash_func(const sd_id128_t *p, struct siphash *state);
32 int id128_compare_func(const sd_id128_t *a, const sd_id128_t *b) _pure_;
33 extern const struct hash_ops id128_hash_ops;