Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
uuid.h File Reference

UUID library - Interface. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <tchatator413/slice.h>

Go to the source code of this file.

Data Structures

struct  uuid4_t
 Version 4 UUID. More...
 

Macros

#define UUID4_REPR_LENGTH   36
 Length of the canonical representation of a version 4 UUID, excluding the null terminator.
 
#define uuid4_of(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)    (uuid4_t) uuid4_init(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)
 Create a new version 4 UUID from the specified values.
 
#define uuid4_init(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)
 

Functions

char * uuid4_repr (uuid4_t uuid, char repr[static const UUID4_REPR_LENGTH])
 Generate the representation of a version 4 UUID.
 
bool uuid4_parse_slice (uuid4_t *out_uuid, slice_t repr_slice)
 
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.
 
bool uuid4_eq (uuid4_t a, uuid4_t b)
 Are two version 4 UUIDs equal?
 

Detailed Description

UUID library - Interface.

Author
Raphaƫl
Date
23/01/2025

Definition in file uuid.h.

Macro Definition Documentation

◆ uuid4_init

#define uuid4_init (   x1,
  x2,
  x3,
  x4,
  x5,
  x6,
  x7,
  x8,
  x9,
  x10,
  x11,
  x12,
  x13,
  x14,
  x15,
  x16 
)
Value:
{ \
.data = { \
x1, \
x2, \
x3, \
x4, \
x5, \
x6, \
x7, \
x8, \
x9, \
x10, \
x11, \
x12, \
x13, \
x14, \
x15, \
x16, \
} \
}

Definition at line 55 of file uuid.h.

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 }

◆ uuid4_of

#define uuid4_of (   x1,
  x2,
  x3,
  x4,
  x5,
  x6,
  x7,
  x8,
  x9,
  x10,
  x11,
  x12,
  x13,
  x14,
  x15,
  x16 
)     (uuid4_t) uuid4_init(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)

Create a new version 4 UUID from the specified values.

Returns
A new UUID Version 4.

Definition at line 52 of file uuid.h.

◆ UUID4_REPR_LENGTH

#define UUID4_REPR_LENGTH   36

Length of the canonical representation of a version 4 UUID, excluding the null terminator.

Definition at line 20 of file uuid.h.

Function Documentation

◆ uuid4_eq()

bool uuid4_eq ( uuid4_t  a,
uuid4_t  b 
)

Are two version 4 UUIDs equal?

Parameters
aThe first UUID.
bThe second UUID.
Returns
A boolean indicating whether a and b are equal.

◆ uuid4_parse()

bool uuid4_parse ( uuid4_t out_uuid,
char const  repr[static const UUID4_REPR_LENGTH] 
)

Parse a version 4 UUID from its canonical representation.

Parameters
out_uuidMutated to the parsed UUID.
reprThe string containing the representation.
Returns
true parsing successful out_uuid is set.
false parsing unsucessful.
Remarks
The syntax ABNF can be found at https://www.rfc-editor.org/rfc/rfc9562.html#section-4-5. Lowercase hex digits are allowed.

◆ uuid4_put()

void uuid4_put ( uuid4_t  uuid,
FILE *  stream 
)

Put the canonical representation of version 4 UUID.

Parameters
uuidThe UUID Version 4 to write.
streamThe stream to write to.

◆ uuid4_repr()

char * uuid4_repr ( uuid4_t  uuid,
char  repr[static const UUID4_REPR_LENGTH] 
)

Generate the representation of a version 4 UUID.

Parameters
uuidThe UUID.
reprThe representation buffer.
Returns
{repr}.
Remarks
This function doesn't add a null terminator at the end of repr.