Distributed File System 1
Distributed file system in C
Loading...
Searching...
No Matches
uuid.c File Reference
#include "uuid.h"
#include <stdbool.h>
#include <stdlib.h>
#include "list_str.h"
#include "lib.h"
#include "log.h"

Functions

 ImplList (HexByte)
bool UUID_eq (UUID l, UUID r)
 Compare 2 UUID's.
Buffer UUID_serialize (UUID in)
 Serialize a UUID into a Buffer.
UUID UUID_deserialize (Buffer in)
 Deserialize a Buffer into a UUID.
uint64_t from_hex (Str str, size_t len)
 Converts a wire format string into a 64-bit integer.
UUID new_uuid (void)
 Creates a new UUID.
HexByte to_hex1 (unsigned char c)
 Converts a single byte to the character representation.
ListHexByte to_hex (uint64_t n)
 Converts an entire 64-bit integer into the character representation.
void ListHexByte_print (ListHexByte list, char end)
 Print a list of hex bytes.

Function Documentation

◆ from_hex()

uint64_t from_hex ( Str str,
size_t max_len )

Converts a wire format string into a 64-bit integer.

Parameters
strthe wire format string to convert
max_lenthe amount of characters to read from the string
Returns
a 64-bit integer with the value of the wire format

◆ ImplList()

ImplList ( HexByte )

◆ ListHexByte_print()

void ListHexByte_print ( ListHexByte list,
char end )

Print a list of hex bytes.

Parameters
listthe list of hex bytes to print
endthe character to end the print with

◆ new_uuid()

UUID new_uuid ( void )

Creates a new UUID.

The UUID comes from /proc/sys/kernel/random/uuid

Returns
a new UUID

◆ to_hex()

ListHexByte to_hex ( uint64_t n)

Converts an entire 64-bit integer into the character representation.

Caller must free memory.

Parameters
nthe number to convert
Returns
the List of bytes the number represents

◆ to_hex1()

HexByte to_hex1 ( unsigned char c)

Converts a single byte to the character representation.

Parameters
cthe byte to convert
Returns
a HexByte that represents that byte

◆ UUID_deserialize()

UUID UUID_deserialize ( Buffer buf)

Deserialize a Buffer into a UUID.

Parameters
bufThe Buffer you want to deserialize
Returns
The UUID that the Buffer represents

◆ UUID_eq()

bool UUID_eq ( UUID lhs,
UUID rhs )

Compare 2 UUID's.

Parameters
lhsthe left-hand side of the equality
rhsthe right-hand side of the equality
Returns
whether the 2 UUID's ar equal or not

◆ UUID_serialize()

Buffer UUID_serialize ( UUID uuid)

Serialize a UUID into a Buffer.

Caller must free memory in Buffer.buf.

Parameters
uuidthe UUID you want to serialize
Returns
the Buffer that the UUID represents