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 bool id128_is_valid(const char *s) _pure_; 12 13 typedef enum Id128Format { 14 ID128_ANY, 15 ID128_PLAIN, /* formatted as 32 hex chars as-is */ 16 ID128_PLAIN_OR_UNINIT, /* formatted as 32 hex chars as-is; allow special "uninitialized" 17 * value when reading from file (id128_read() and id128_read_fd()). 18 * 19 * This format should be used when reading a machine-id file. */ 20 ID128_UUID, /* formatted as 36 character uuid string */ 21 _ID128_FORMAT_MAX, 22 } Id128Format; 23 24 int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret); 25 int id128_read(const char *p, Id128Format f, sd_id128_t *ret); 26 27 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync); 28 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync); 29 30 void id128_hash_func(const sd_id128_t *p, struct siphash *state); 31 int id128_compare_func(const sd_id128_t *a, const sd_id128_t *b) _pure_; 32 extern const struct hash_ops id128_hash_ops; 33 34 sd_id128_t id128_make_v4_uuid(sd_id128_t id); 35 36 int id128_get_product(sd_id128_t *ret); 37 38 int id128_equal_string(const char *s, sd_id128_t id); 39