util.c File Reference

Go to the source code of this file.

Functions

void xprintf_rdf (ldns_rdf *rd)
void xprintf_rr (ldns_rr *rr)
ldns_lookup_tableldns_lookup_by_name (ldns_lookup_table *table, const char *name)
ldns_lookup_tableldns_lookup_by_id (ldns_lookup_table *table, int id)
int ldns_get_bit (uint8_t bits[], size_t index)
 Returns the value of the specified bit The bits are counted from left to right, so bit #0 is the left most bit.
int ldns_get_bit_r (uint8_t bits[], size_t index)
 Returns the value of the specified bit The bits are counted from right to left, so bit #0 is the right most bit.
void ldns_set_bit (uint8_t *byte, int bit_nr, bool value)
 sets the specified bit in the specified byte to 1 if value is true, 0 if false The bits are counted from right to left, so bit #0 is the right most bit.
int ldns_hexdigit_to_int (char ch)
 Returns the int value of the given (hex) digit.
char ldns_int_to_hexdigit (int i)
 Returns the char (hex) representation of the given int.
const char * ldns_version (void)
 Show the internal library version.
time_t mktime_from_utc (const struct tm *tm)
 Convert TM to seconds since epoch (midnight, January 1st, 1970).
int ldns_init_random (FILE *fd, unsigned int size)
 Seed the random function.


Function Documentation

void xprintf_rdf ( ldns_rdf rd  ) 

Definition at line 30 of file util.c.

References ldns_rdf_data(), ldns_rdf_get_type(), and ldns_rdf_size().

void xprintf_rr ( ldns_rr rr  ) 

Definition at line 40 of file util.c.

References ldns_struct_rr::_rdata_fields, ldns_rr_rd_count(), and xprintf_rdf().

ldns_lookup_table* ldns_lookup_by_name ( ldns_lookup_table table,
const char *  name 
)

Definition at line 54 of file util.c.

References ldns_struct_lookup_table::name.

ldns_lookup_table* ldns_lookup_by_id ( ldns_lookup_table table,
int  id 
)

Definition at line 65 of file util.c.

References ldns_struct_lookup_table::id, and ldns_struct_lookup_table::name.

int ldns_get_bit ( uint8_t  bits[],
size_t  index 
)

Returns the value of the specified bit The bits are counted from left to right, so bit #0 is the left most bit.

Parameters:
[in] bits array holding the bits
[in] index to the wanted bit
Returns:

Definition at line 76 of file util.c.

int ldns_get_bit_r ( uint8_t  bits[],
size_t  index 
)

Returns the value of the specified bit The bits are counted from right to left, so bit #0 is the right most bit.

Parameters:
[in] bits array holding the bits
[in] index to the wanted bit
Returns:
1 or 0 depending no the bit state

Definition at line 86 of file util.c.

void ldns_set_bit ( uint8_t *  byte,
int  bit_nr,
bool  value 
)

sets the specified bit in the specified byte to 1 if value is true, 0 if false The bits are counted from right to left, so bit #0 is the right most bit.

Parameters:
[in] byte the bit to set the bit in
[in] bit_nr the bit to set (0 <= n <= 7)
[in] value whether to set the bit to 1 or 0
Returns:
1 or 0 depending no the bit state

Definition at line 96 of file util.c.

int ldns_hexdigit_to_int ( char  ch  ) 

Returns the int value of the given (hex) digit.

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

Definition at line 108 of file util.c.

char ldns_int_to_hexdigit ( int  ch  ) 

Returns the char (hex) representation of the given int.

Parameters:
[in] ch the int to convert
Returns:
the converted hex char

Definition at line 133 of file util.c.

const char* ldns_version ( void   ) 

Show the internal library version.

Returns:
a string with the version in it

Definition at line 158 of file util.c.

References LDNS_VERSION.

time_t 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] tm a struct tm* with the date
Returns:
the seconds since epoch

Definition at line 186 of file util.c.

int ldns_init_random ( FILE *  fd,
unsigned int  size 
)

Seed the random function.

If you need more entropy, or have no openssl available, this function MUST be called at the start of the program

If openssl *is* available, this function just adds more entropy

Definition at line 222 of file util.c.

References LDNS_FREE, and LDNS_XMALLOC.


Generated on Sun Dec 2 07:36:05 2007 for ldns by  doxygen 1.4.7