]> git.ipfire.org Git - thirdparty/systemd.git/blame - 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
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
910fd145
LP
2#pragma once
3
910fd145
LP
4#include <stdbool.h>
5
6#include "sd-id128.h"
4b58153d
LP
7
8#include "hash-funcs.h"
910fd145
LP
9#include "macro.h"
10
11char *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
16bool id128_is_valid(const char *s) _pure_;
17
18typedef 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
25int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret);
26int id128_read(const char *p, Id128Format f, sd_id128_t *ret);
27
15b1248a
LP
28int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync);
29int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync);
4b58153d 30
7a08d314
YW
31void id128_hash_func(const sd_id128_t *p, struct siphash *state);
32int id128_compare_func(const sd_id128_t *a, const sd_id128_t *b) _pure_;
4b58153d 33extern const struct hash_ops id128_hash_ops;