duration.h File Reference

Go to the source code of this file.

Data Structures

struct  ldns_duration_struct
 

Typedefs

typedef struct ldns_duration_struct ldns_duration_type
 This file is copied from the OpenDNSSEC source repository and only slightly adapted to make it fit. More...
 

Functions

ldns_duration_typeldns_duration_create (void)
 Create a new 'instant' duration. More...
 
int ldns_duration_compare (const ldns_duration_type *d1, const ldns_duration_type *d2)
 Compare durations. More...
 
ldns_duration_typeldns_duration_create_from_string (const char *str)
 Create a duration from string. More...
 
char * ldns_duration2string (const ldns_duration_type *duration)
 Convert a duration to a string. More...
 
time_t ldns_duration2time (const ldns_duration_type *duration)
 Convert a duration to a time. More...
 
void ldns_duration_cleanup (ldns_duration_type *duration)
 Clean up duration. More...
 

Typedef Documentation

◆ ldns_duration_type

This file is copied from the OpenDNSSEC source repository and only slightly adapted to make it fit.

Durations. Duration.

Definition at line 1 of file duration.h.

Function Documentation

◆ ldns_duration_create()

ldns_duration_type* ldns_duration_create ( void  )

Create a new 'instant' duration.

Returns
ldns_duration_type* created duration

Create a new 'instant' duration.

Durations. Create a new 'instant' duration.

Definition at line 54 of file duration.c.

References ldns_duration_struct::days, ldns_duration_struct::hours, ldns_duration_struct::minutes, ldns_duration_struct::months, ldns_duration_struct::seconds, ldns_duration_struct::weeks, and ldns_duration_struct::years.

◆ ldns_duration_compare()

int ldns_duration_compare ( const ldns_duration_type d1,
const ldns_duration_type d2 
)

Compare durations.

Parameters
[in]d1one duration
[in]d2another duration
Returns
int 0 if equal, -1 if d1 < d2, 1 if d2 < d1

Definition at line 78 of file duration.c.

References ldns_duration_struct::days, ldns_duration_struct::hours, ldns_duration_struct::minutes, ldns_duration_struct::months, ldns_duration_struct::seconds, ldns_duration_struct::weeks, and ldns_duration_struct::years.

◆ ldns_duration_create_from_string()

ldns_duration_type* ldns_duration_create_from_string ( const char *  str)

Create a duration from string.

Parameters
[in]strstring-format duration
Returns
ldns_duration_type* created duration

Definition at line 118 of file duration.c.

References ldns_duration_struct::days, ldns_duration_struct::hours, ldns_duration_cleanup(), ldns_duration_create(), ldns_duration_struct::minutes, ldns_duration_struct::months, ldns_duration_struct::seconds, ldns_duration_struct::weeks, and ldns_duration_struct::years.

◆ ldns_duration2string()

char* ldns_duration2string ( const ldns_duration_type duration)

Convert a duration to a string.

Parameters
[in]durationduration to be converted
Returns
char* string-format duration

Definition at line 211 of file duration.c.

◆ ldns_duration2time()

time_t ldns_duration2time ( const ldns_duration_type duration)

Convert a duration to a time.

Parameters
[in]durationduration to be converted
Returns
time_t time-format duration

Definition at line 246 of file duration.c.

References ldns_duration_struct::days, ldns_duration_struct::hours, ldns_duration_struct::minutes, ldns_duration_struct::months, ldns_duration_struct::seconds, ldns_duration_struct::weeks, and ldns_duration_struct::years.

◆ ldns_duration_cleanup()

void ldns_duration_cleanup ( ldns_duration_type duration)

Clean up duration.

Parameters
[in]durationduration to be cleaned up

Definition at line 274 of file duration.c.