Distributed File System 1
Distributed file system in C
Loading...
Searching...
No Matches
uuid.h
Go to the documentation of this file.
1/* lib/uuid.h
2 *
3 * Has UUID utilities.
4 *
5 */
6#ifndef UUID_H_
7#define UUID_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/* ----- Includes ----- */
14
15#include <stdint.h>
16#include <string.h>
17#include "lib.h"
18#include "list.h"
19
20/* ----- Types ----- */
21
24typedef struct {
25 uint32_t id1;
26 uint16_t id2;
27 uint16_t id3;
28 uint16_t id4;
29 uint64_t id5 : 48;
30} UUID;
31
33typedef struct {
34 char uuid[39];
35} UUID_Str;
36
37
39typedef struct {
40 char l;
41 char r;
42} HexByte;
43
44/* ----- Functions ----- */
45
47
48
58UUID_Str utoa(UUID uuid);
59
66
72
78uint64_t from_hex(Str str, size_t max_len);
79
84UUID new_uuid(void);
85
90HexByte to_hex1(unsigned char c);
91
97ListHexByte to_hex(uint64_t n);
98
103void ListHexByte_print(ListHexByte list, char end);
104
110bool UUID_eq(UUID lhs, UUID rhs);
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif // UUID_H_
const char * Str
String type.
Definition lib.h:73
#define DefList(type)
Definition list.h:93
void list(Enchufe cliente)
Definition meta-data.c:14
Byte buffer.
Definition lib.h:92
A hexadecimal Byte.
Definition uuid.h:39
char r
lower nibble
Definition uuid.h:41
char l
upper nibble
Definition uuid.h:40
This is useful for printing UUID's.
Definition uuid.h:33
char uuid[39]
enough space for the UUID in hex (34 characters) and 4 dashes and a null character.
Definition uuid.h:34
UUID type Layout taken from: https://en.wikipedia.org/wiki/Universally_unique_identifier#Binary_repre...
Definition uuid.h:24
uint32_t id1
time_high wire format
Definition uuid.h:25
uint64_t id5
node wire format
Definition uuid.h:29
uint16_t id2
time_low wire format
Definition uuid.h:26
uint16_t id3
reserved wire format
Definition uuid.h:27
uint16_t id4
family wire format
Definition uuid.h:28
void ListHexByte_print(ListHexByte list, char end)
Print a list of hex bytes.
Definition uuid.c:149
Buffer UUID_serialize(UUID uuid)
Serialize a UUID into a Buffer.
Definition uuid.c:40
UUID new_uuid(void)
Creates a new UUID.
Definition uuid.c:74
HexByte to_hex1(unsigned char c)
Converts a single byte to the character representation.
Definition uuid.c:131
UUID UUID_deserialize(Buffer buf)
Deserialize a Buffer into a UUID.
Definition uuid.c:44
bool UUID_eq(UUID lhs, UUID rhs)
Compare 2 UUID's.
Definition uuid.c:32
ListHexByte to_hex(uint64_t n)
Converts an entire 64-bit integer into the character representation.
Definition uuid.c:139
uint64_t from_hex(Str str, size_t max_len)
Converts a wire format string into a 64-bit integer.
Definition uuid.c:56