/src/dovecot/src/lib/guid.h
Line | Count | Source |
1 | | #ifndef GUID_H |
2 | | #define GUID_H |
3 | | |
4 | 0 | #define GUID_128_SIZE 16 |
5 | | typedef uint8_t guid_128_t[GUID_128_SIZE]; |
6 | | |
7 | | #define GUID_128_HOST_HASH_SIZE 4 |
8 | | |
9 | | ARRAY_DEFINE_TYPE(guid_128_t, guid_128_t); |
10 | | |
11 | | /* Very liberal check, checks only version. */ |
12 | | #define GUID_128_IS_UUID4(uuid) \ |
13 | | (((uuid)[6] & 0xF0) == 0x40) |
14 | | |
15 | | enum uuid_format { |
16 | | FORMAT_RECORD, |
17 | | FORMAT_COMPACT, |
18 | | FORMAT_MICROSOFT, |
19 | | }; |
20 | | /* Generate a GUID (contains host name) */ |
21 | | const char *guid_generate(void); |
22 | | /* Generate 128 bit GUID */ |
23 | | void guid_128_generate(guid_128_t guid_r); |
24 | | /* Generate UUID4gen1 */ |
25 | | void guid_128_uuid4_generate(guid_128_t guid_r); |
26 | | |
27 | | /* Returns TRUE if GUID is empty (not set / unknown). */ |
28 | | bool guid_128_is_empty(const guid_128_t guid) ATTR_PURE; |
29 | | static inline void guid_128_empty(guid_128_t guid) |
30 | 0 | { |
31 | 0 | memset(guid, 0, GUID_128_SIZE); |
32 | 0 | } Unexecuted instantiation: smtp-server-connection.c:guid_128_empty Unexecuted instantiation: smtp-server-cmd-starttls.c:guid_128_empty Unexecuted instantiation: var-expand.c:guid_128_empty Unexecuted instantiation: guid.c:guid_128_empty |
33 | | /* Returns TRUE if two GUIDs are equal. */ |
34 | | bool guid_128_equals(const guid_128_t guid1, const guid_128_t guid2) ATTR_PURE; |
35 | | /* Copy GUID */ |
36 | | static inline void guid_128_copy(guid_128_t dest, const guid_128_t src) |
37 | 0 | { |
38 | 0 | memcpy(dest, src, GUID_128_SIZE); |
39 | 0 | } Unexecuted instantiation: smtp-server-connection.c:guid_128_copy Unexecuted instantiation: smtp-server-cmd-starttls.c:guid_128_copy Unexecuted instantiation: var-expand.c:guid_128_copy Unexecuted instantiation: guid.c:guid_128_copy |
40 | | |
41 | | /* Returns GUID as a hex string. */ |
42 | | const char *guid_128_to_string(const guid_128_t guid); |
43 | | /* Parse GUID from a string. Returns 0 if ok, -1 if GUID isn't valid. */ |
44 | | int guid_128_from_string(const char *str, guid_128_t guid_r); |
45 | | |
46 | | /* Returns GUID as a UUID hex string. */ |
47 | | const char *guid_128_to_uuid_string(const guid_128_t guid, enum uuid_format format); |
48 | | /* Parse GUID from a UUID string. Returns 0 if ok, -1 if UUID isn't valid. */ |
49 | | int guid_128_from_uuid_string(const char *str, guid_128_t guid_r); |
50 | | |
51 | | /* guid_128 hash/cmp functions for hash.h */ |
52 | | unsigned int guid_128_hash(const guid_128_t guid) ATTR_PURE; |
53 | | int guid_128_cmp(const guid_128_t guid1, const guid_128_t guid2) ATTR_PURE; |
54 | | |
55 | | /* Return the hash of host used by guid_128_generate(). */ |
56 | | void guid_128_host_hash_get(const char *host, |
57 | | unsigned char hash_r[STATIC_ARRAY GUID_128_HOST_HASH_SIZE]); |
58 | | |
59 | | #endif |