Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
uuid.h
Go to the documentation of this file.
1
5
6#ifndef UUID_H
7#define UUID_H
8
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdio.h>
12#include <tchatator413/slice.h>
13
15typedef struct {
16 uint8_t data[16];
17} uuid4_t;
18
20#define UUID4_REPR_LENGTH 36
21
27char *uuid4_repr(uuid4_t uuid, char repr[static const UUID4_REPR_LENGTH]);
28
29bool uuid4_parse_slice(uuid4_t *out_uuid, slice_t repr_slice);
30
37bool uuid4_parse(uuid4_t *out_uuid, char const repr[static const UUID4_REPR_LENGTH]);
38
42void uuid4_put(uuid4_t uuid, FILE *stream);
43
49
52#define uuid4_of(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) \
53 (uuid4_t) uuid4_init(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)
54
55#define uuid4_init(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) \
56 { \
57 .data = { \
58 x1, \
59 x2, \
60 x3, \
61 x4, \
62 x5, \
63 x6, \
64 x7, \
65 x8, \
66 x9, \
67 x10, \
68 x11, \
69 x12, \
70 x13, \
71 x14, \
72 x15, \
73 x16, \
74 } \
75 }
76
77#endif // UUID_H
slice data strucutre - Interface
A memory slice.
Definition slice.h:12
Version 4 UUID.
Definition uuid.h:15
char * uuid4_repr(uuid4_t uuid, char repr[static const UUID4_REPR_LENGTH])
Generate the representation of a version 4 UUID.
#define UUID4_REPR_LENGTH
Length of the canonical representation of a version 4 UUID, excluding the null terminator.
Definition uuid.h:20
bool uuid4_eq(uuid4_t a, uuid4_t b)
Are two version 4 UUIDs equal?
bool uuid4_parse(uuid4_t *out_uuid, char const repr[static const UUID4_REPR_LENGTH])
Parse a version 4 UUID from its canonical representation.
void uuid4_put(uuid4_t uuid, FILE *stream)
Put the canonical representation of version 4 UUID.