Electroneum
parseutil.h File Reference

Go to the source code of this file.

Classes

struct  sldns_struct_lookup_table
 

Typedefs

typedef struct sldns_struct_lookup_table sldns_lookup_table
 

Functions

sldns_lookup_tablesldns_lookup_by_name (sldns_lookup_table table[], const char *name)
 
sldns_lookup_tablesldns_lookup_by_id (sldns_lookup_table table[], int id)
 
time_t sldns_mktime_from_utc (const struct tm *tm)
 
struct tm * sldns_serial_arithmetics_gmtime_r (int32_t time, time_t now, struct tm *result)
 
uint32_t sldns_str2period (const char *nptr, const char **endptr)
 
int sldns_hexdigit_to_int (char ch)
 
size_t sldns_b64_ntop_calculate_size (size_t srcsize)
 
int sldns_b64_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize)
 
size_t sldns_b64_pton_calculate_size (size_t srcsize)
 
int sldns_b64_pton (char const *src, uint8_t *target, size_t targsize)
 
size_t sldns_b32_ntop_calculate_size (size_t src_data_length)
 
size_t sldns_b32_ntop_calculate_size_no_padding (size_t src_data_length)
 
int sldns_b32_ntop (const uint8_t *src_data, size_t src_data_length, char *target_text_buffer, size_t target_text_buffer_size)
 
int sldns_b32_ntop_extended_hex (const uint8_t *src_data, size_t src_data_length, char *target_text_buffer, size_t target_text_buffer_size)
 
size_t sldns_b32_pton_calculate_size (size_t src_text_length)
 
int sldns_b32_pton (const char *src_text, size_t src_text_length, uint8_t *target_data_buffer, size_t target_data_buffer_size)
 
int sldns_b32_pton_extended_hex (const char *src_text, size_t src_text_length, uint8_t *target_data_buffer, size_t target_data_buffer_size)
 
int sldns_parse_escape (uint8_t *ch_p, const char **str_p)
 
int sldns_parse_char (uint8_t *ch_p, const char **str_p)
 

Detailed Description

Utility functions for parsing, base32(DNS variant) and base64 encoding and decoding, Hex, Time units, Escape codes.

Definition in file parseutil.h.

Typedef Documentation

◆ sldns_lookup_table

Definition at line 31 of file parseutil.h.

Function Documentation

◆ sldns_b32_ntop()

int sldns_b32_ntop ( const uint8_t src_data,
size_t  src_data_length,
char *  target_text_buffer,
size_t  target_text_buffer_size 
)

◆ sldns_b32_ntop_calculate_size()

size_t sldns_b32_ntop_calculate_size ( size_t  src_data_length)

calculates the size needed to store the result of b32_ntop

◆ sldns_b32_ntop_calculate_size_no_padding()

size_t sldns_b32_ntop_calculate_size_no_padding ( size_t  src_data_length)

◆ sldns_b32_ntop_extended_hex()

int sldns_b32_ntop_extended_hex ( const uint8_t src_data,
size_t  src_data_length,
char *  target_text_buffer,
size_t  target_text_buffer_size 
)

◆ sldns_b32_pton()

int sldns_b32_pton ( const char *  src_text,
size_t  src_text_length,
uint8_t target_data_buffer,
size_t  target_data_buffer_size 
)

◆ sldns_b32_pton_calculate_size()

size_t sldns_b32_pton_calculate_size ( size_t  src_text_length)

calculates the size needed to store the result of b32_pton

◆ sldns_b32_pton_extended_hex()

int sldns_b32_pton_extended_hex ( const char *  src_text,
size_t  src_text_length,
uint8_t target_data_buffer,
size_t  target_data_buffer_size 
)

◆ sldns_b64_ntop()

int sldns_b64_ntop ( uint8_t const *  src,
size_t  srclength,
char *  target,
size_t  targsize 
)

◆ sldns_b64_ntop_calculate_size()

size_t sldns_b64_ntop_calculate_size ( size_t  srcsize)

calculates the size needed to store the result of b64_ntop

◆ sldns_b64_pton()

int sldns_b64_pton ( char const *  src,
uint8_t target,
size_t  targsize 
)

◆ sldns_b64_pton_calculate_size()

size_t sldns_b64_pton_calculate_size ( size_t  srcsize)

calculates the size needed to store the result of sldns_b64_pton

◆ sldns_hexdigit_to_int()

int sldns_hexdigit_to_int ( char  ch)

Returns the int value of the given (hex) digit

Parameters
[in]chthe hex char to convert
Returns
the converted decimal value

◆ sldns_lookup_by_id()

sldns_lookup_table* sldns_lookup_by_id ( sldns_lookup_table  table[],
int  id 
)

Looks up the table entry by id, returns NULL if not found.

Parameters
[in]tablethe lookup table to search in
[in]idwhat to search for
Returns
the item found

◆ sldns_lookup_by_name()

sldns_lookup_table* sldns_lookup_by_name ( sldns_lookup_table  table[],
const char *  name 
)

Looks up the table entry by name, returns NULL if not found.

Parameters
[in]tablethe lookup table to search in
[in]namewhat to search for
Returns
the item found

◆ sldns_mktime_from_utc()

time_t sldns_mktime_from_utc ( const struct tm *  tm)

Convert TM to seconds since epoch (midnight, January 1st, 1970). Like timegm(3), which is not always available.

Parameters
[in]tma struct tm* with the date
Returns
the seconds since epoch

◆ sldns_parse_char()

int sldns_parse_char ( uint8_t ch_p,
const char **  str_p 
)

Parse one character, with escape codes,

Parameters
ch_pthe parsed character
str_pthe string. moved along for characters read.
Returns
0 on error

◆ sldns_parse_escape()

int sldns_parse_escape ( uint8_t ch_p,
const char **  str_p 
)

◆ sldns_serial_arithmetics_gmtime_r()

struct tm* sldns_serial_arithmetics_gmtime_r ( int32_t  time,
time_t  now,
struct tm *  result 
)

The function interprets time as the number of seconds since epoch with respect to now using serial arithmetics (rfc1982). That number of seconds is then converted to broken-out time information. This is especially usefull when converting the inception and expiration fields of RRSIG records.

Parameters
[in]timenumber of seconds since epoch (midnight, January 1st, 1970) to be interpreted as a serial arithmetics number relative to now.
[in]nownumber of seconds since epoch (midnight, January 1st, 1970) to which the time value is compared to determine the final value.
[out]resultthe struct with the broken-out time information
Returns
result on success or NULL on error

◆ sldns_str2period()

uint32_t sldns_str2period ( const char *  nptr,
const char **  endptr 
)

converts a ttl value (like 5d2h) to a long.

Parameters
[in]nptrthe start of the string
[out]endptrpoints to the last char in case of error
Returns
the convert duration value