chiark / gitweb /
Prep v232: Add libelogind.sym entries for version 232.
[elogind.git] / src / libelogind / sd-id128 / id128-util.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2016 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   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 systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdbool.h>
23
24 #include "sd-id128.h"
25
26 #include "hash-funcs.h"
27 #include "macro.h"
28
29 char *id128_to_uuid_string(sd_id128_t id, char s[37]);
30
31 /* Like SD_ID128_FORMAT_STR, but formats as UUID, not in plain format */
32 #define ID128_UUID_FORMAT_STR "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
33
34 bool id128_is_valid(const char *s) _pure_;
35
36 typedef enum Id128Format {
37         ID128_ANY,
38         ID128_PLAIN,  /* formatted as 32 hex chars as-is */
39         ID128_UUID,   /* formatted as 36 character uuid string */
40         _ID128_FORMAT_MAX,
41 } Id128Format;
42
43 int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret);
44 int id128_read(const char *p, Id128Format f, sd_id128_t *ret);
45
46 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync);
47 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync);
48
49 void id128_hash_func(const void *p, struct siphash *state);
50 int id128_compare_func(const void *a, const void *b) _pure_;
51 extern const struct hash_ops id128_hash_ops;