|
unbound 0.1
|
Utility functions for parsing, base32(DNS variant) and base64 encoding and decoding, Hex, Time units, Escape codes. More...
#include "config.h"#include "sldns/parseutil.h"#include <sys/time.h>#include <time.h>#include <ctype.h>Macros | |
| #define | LDNS_MOD(x, y) |
| #define | LDNS_DIV(x, y) |
Functions | |
| sldns_lookup_table * | sldns_lookup_by_name (sldns_lookup_table *table, const char *name) |
| sldns_lookup_table * | sldns_lookup_by_id (sldns_lookup_table *table, int id) |
| static int | is_leap_year (int year) |
| static int | leap_days (int y1, int y2) |
| time_t | sldns_mktime_from_utc (const struct tm *tm) |
| Convert TM to seconds since epoch (midnight, January 1st, 1970). | |
| static void | sldns_year_and_yday_from_days_since_epoch (int64_t days, struct tm *result) |
| static void | sldns_mon_and_mday_from_year_and_yday (struct tm *result) |
| static void | sldns_wday_from_year_and_yday (struct tm *result) |
| static struct tm * | sldns_gmtime64_r (int64_t clock, struct tm *result) |
| static int64_t | sldns_serial_arithmetics_time (int32_t time, time_t now) |
| 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). | |
| int | sldns_hexdigit_to_int (char ch) |
| Returns the int value of the given (hex) digit. | |
| uint32_t | sldns_str2period (const char *nptr, const char **endptr, int *overflow) |
| converts a ttl value (like 5d2h) to a long. | |
| int | sldns_parse_escape (uint8_t *ch_p, const char **str_p) |
| int | sldns_parse_char (uint8_t *ch_p, const char **str_p) |
| parse one character, with escape codes | |
| size_t | sldns_b32_ntop_calculate_size (size_t src_data_length) |
| calculates the size needed to store the result of b32_ntop | |
| size_t | sldns_b32_ntop_calculate_size_no_padding (size_t src_data_length) |
| static int | sldns_b32_ntop_base (const uint8_t *src, size_t src_sz, char *dst, size_t dst_sz, int extended_hex, int add_padding) |
| int | sldns_b32_ntop (const uint8_t *src, size_t src_sz, char *dst, size_t dst_sz) |
| int | sldns_b32_ntop_extended_hex (const uint8_t *src, size_t src_sz, char *dst, size_t dst_sz) |
| size_t | sldns_b32_pton_calculate_size (size_t src_text_length) |
| calculates the size needed to store the result of b32_pton | |
| static int | sldns_b32_pton_base (const char *src, size_t src_sz, uint8_t *dst, size_t dst_sz, int extended_hex, int check_padding) |
| int | sldns_b32_pton (const char *src, size_t src_sz, uint8_t *dst, size_t dst_sz) |
| int | sldns_b32_pton_extended_hex (const char *src, size_t src_sz, uint8_t *dst, size_t dst_sz) |
| size_t | sldns_b64_ntop_calculate_size (size_t srcsize) |
| calculates the size needed to store the result of b64_ntop | |
| static int | sldns_b64_ntop_base (uint8_t const *src, size_t srclength, char *target, size_t targsize, int base64url, int padding) |
| int | sldns_b64_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
| int | sldns_b64url_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
| size_t | sldns_b64_pton_calculate_size (size_t srcsize) |
| calculates the size needed to store the result of sldns_b64_pton | |
| static int | sldns_b64_pton_base (char const *src, size_t srcsize, uint8_t *target, size_t targsize, int base64url) |
| int | sldns_b64_pton (char const *src, uint8_t *target, size_t targsize) |
| int | sldns_b64url_pton (char const *src, size_t srcsize, uint8_t *target, size_t targsize) |
| int | sldns_b64_contains_nonurl (char const *src, size_t srcsize) |
Variables | |
| static const int | mdays [] |
| static const int | leap_year_mdays [] |
Utility functions for parsing, base32(DNS variant) and base64 encoding and decoding, Hex, Time units, Escape codes.
| #define LDNS_MOD | ( | x, | |
| y ) |
| #define LDNS_DIV | ( | x, | |
| y ) |
| 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.
| [in] | tm | a struct tm* with the date |
References sldns_mktime_from_utc().
Referenced by cfg_convert_timeval(), sldns_lookup_by_id(), sldns_mktime_from_utc(), sldns_str2wire_time_buf(), and xml_convertdate().
| 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 useful when converting the inception and expiration fields of RRSIG records.
| [in] | time | number of seconds since epoch (midnight, January 1st, 1970) to be interpreted as a serial arithmetics number relative to now. |
| [in] | now | number of seconds since epoch (midnight, January 1st, 1970) to which the time value is compared to determine the final value. |
| [out] | result | the struct with the broken-out time information |
References sldns_serial_arithmetics_gmtime_r().
Referenced by sldns_lookup_by_id(), sldns_serial_arithmetics_gmtime_r(), and sldns_wire2str_time_scan().
| int sldns_hexdigit_to_int | ( | char | ch | ) |
Returns the int value of the given (hex) digit.
| [in] | ch | the hex char to convert |
References sldns_hexdigit_to_int().
Referenced by cfg_parse_nsid(), hex_pton(), hex_to_buf(), rrinternal_spool_hex(), sldns_hexdigit_to_int(), sldns_lookup_by_id(), sldns_str2wire_atma_buf(), sldns_str2wire_hex_buf(), sldns_str2wire_nsap_buf(), and sldns_str2wire_nsec3_salt_buf().
| uint32_t sldns_str2period | ( | const char * | nptr, |
| const char ** | endptr, | ||
| int * | overflow ) |
converts a ttl value (like 5d2h) to a long.
| [in] | nptr | the start of the string |
| [out] | endptr | points to the last char in case of error |
| [out] | overflow | returns if the string causes integer overflow error, the number is too big, string of digits too long. |
References sldns_str2period().
Referenced by http_parse_ttl(), rrinternal_get_ttl(), sldns_fp2wire_rr_buf(), sldns_lookup_by_id(), sldns_str2period(), and sldns_str2wire_period_buf().
| int sldns_parse_char | ( | uint8_t * | ch_p, |
| const char ** | str_p ) |
parse one character, with escape codes
Parse one character, with escape codes,.
parse one character, with escape codes
| ch_p | the parsed character |
| str_p | the string. moved along for characters read. |
References sldns_parse_char().
Referenced by sldns_lookup_by_id(), sldns_parse_char(), sldns_str2wire_long_str_buf(), and sldns_str2wire_str_buf().
| size_t sldns_b32_ntop_calculate_size | ( | size_t | src_data_length | ) |
calculates the size needed to store the result of b32_ntop
References sldns_b32_ntop_calculate_size().
Referenced by sldns_b32_ntop_calculate_size(), sldns_lookup_by_id(), and sldns_wire2str_b32_ext_scan().
| size_t sldns_b32_pton_calculate_size | ( | size_t | src_text_length | ) |
calculates the size needed to store the result of b32_pton
References sldns_b32_pton_calculate_size().
Referenced by sldns_b32_pton_calculate_size(), sldns_lookup_by_id(), and sldns_str2wire_b32_ext_buf().
| size_t sldns_b64_ntop_calculate_size | ( | size_t | srcsize | ) |
calculates the size needed to store the result of b64_ntop
References sldns_b64_ntop_calculate_size().
Referenced by sldns_b64_ntop_calculate_size(), sldns_lookup_by_id(), and sldns_wire2str_b64_scan_num().
| size_t sldns_b64_pton_calculate_size | ( | size_t | srcsize | ) |
calculates the size needed to store the result of sldns_b64_pton
References sldns_b64_pton_calculate_size().
Referenced by sldns_b64_pton_calculate_size(), sldns_lookup_by_id(), and sldns_str2wire_b64_buf().
|
static |
|
static |