util.h File Reference

Go to the source code of this file.

Data Structures

struct  ldns_struct_lookup_table

Defines

#define dprintf(X, Y)   fprintf(stderr, (X), (Y))
#define LDNS_VERSION   "1.0.1"
#define INLINE   static inline
 splint static inline workaround
#define LDNS_MALLOC(type)   LDNS_XMALLOC(type, 1)
 Memory management macro's.
#define LDNS_XMALLOC(type, count)   ((type *) malloc((count) * sizeof(type)))
#define LDNS_REALLOC(ptr, type)   LDNS_XREALLOC((ptr), type, 1)
#define LDNS_XREALLOC(ptr, type, count)   ((type *) realloc((ptr), (count) * sizeof(type)))
#define LDNS_FREE(ptr)   do { free((ptr)); (ptr) = NULL; } while (0)
#define LDNS_DEP   printf("DEPRECATED FUNCTION!\n");

Typedefs

typedef ldns_struct_lookup_table ldns_lookup_table

Functions

ldns_lookup_tableldns_lookup_by_name (ldns_lookup_table table[], const char *name)
 Looks up the table entry by name, returns NULL if not found.
ldns_lookup_tableldns_lookup_by_id (ldns_lookup_table table[], int id)
 Looks up the table entry by id, returns NULL if not found.
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 ch)
 Returns the char (hex) representation of the given int.
const char * ldns_version (void)
 Show the internal library version.
int ldns_serial (uint32_t s1, uint32_t s2)
 Implements serial arith.
time_t mktime_from_utc (const struct tm *tm)
 Convert TM to seconds since epoch (midnight, January 1st, 1970).


Define Documentation

#define dprintf X,
 )     fprintf(stderr, (X), (Y))
 

Definition at line 18 of file util.h.

#define INLINE   static inline
 

splint static inline workaround

Definition at line 29 of file util.h.

#define LDNS_DEP   printf("DEPRECATED FUNCTION!\n");
 

Definition at line 47 of file util.h.

#define LDNS_FREE ptr   )     do { free((ptr)); (ptr) = NULL; } while (0)
 

Definition at line 44 of file util.h.

#define LDNS_MALLOC type   )     LDNS_XMALLOC(type, 1)
 

Memory management macro's.

Definition at line 35 of file util.h.

#define LDNS_REALLOC ptr,
type   )     LDNS_XREALLOC((ptr), type, 1)
 

Definition at line 39 of file util.h.

#define LDNS_VERSION   "1.0.1"
 

Definition at line 21 of file util.h.

#define LDNS_XMALLOC type,
count   )     ((type *) malloc((count) * sizeof(type)))
 

Definition at line 37 of file util.h.

#define LDNS_XREALLOC ptr,
type,
count   )     ((type *) realloc((ptr), (count) * sizeof(type)))
 

Definition at line 41 of file util.h.


Typedef Documentation

typedef struct ldns_struct_lookup_table ldns_lookup_table
 

Definition at line 122 of file util.h.


Function Documentation

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.

int ldns_hexdigit_to_int char  ch  ) 
 

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

char ldns_int_to_hexdigit int  ch  ) 
 

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

ldns_lookup_table* ldns_lookup_by_id ldns_lookup_table  table[],
int  id
 

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

ldns_lookup_table* ldns_lookup_by_name ldns_lookup_table  table[],
const char *  name
 

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

int ldns_serial uint32_t  s1,
uint32_t  s2
 

Implements serial arith.

RFC 1982

Parameters:
[in] s1 the first serial
[in] s2 the second serial
Returns:
0 if s1 == s2

-1 if s1 < s2

+1 if s1 > s2

-2 undef

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

const char* ldns_version void   ) 
 

Show the internal library version.

Returns:
a string with the version in it

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.


Generated on Mon Feb 20 15:41:27 2006 for ldns by  doxygen 1.4.6