OpenDNSSEC-signer 1.2.1
Data Structures | Typedefs | Functions

/build/buildd-opendnssec_1.2.1.dfsg-1-mips-p9AT07/opendnssec-1.2.1.dfsg/signer/src/util/duration.h File Reference

#include "config.h"
#include <stdint.h>
#include <time.h>
Include dependency graph for duration.h:

Go to the source code of this file.

Data Structures

struct  duration_struct

Typedefs

typedef struct duration_struct duration_type

Functions

duration_typeduration_create (void)
int duration_compare (duration_type *d1, duration_type *d2)
duration_typeduration_create_from_string (const char *str)
char * duration2string (duration_type *duration)
time_t duration2time (duration_type *duration)
time_t se_rand (time_t mod)
time_t time_minimum (time_t a, time_t b)
time_t time_maximum (time_t a, time_t b)
void time_itoa (time_t n, char *s)
uint32_t time_datestamp (time_t tt, const char *format, char **str)
time_t timeshift2time (const char *time)
time_t time_now (void)
void duration_cleanup (duration_type *duration)

Typedef Documentation

Durations. Duration.

Definition at line 46 of file duration.h.


Function Documentation

char* duration2string ( duration_type duration)

Convert a duration to a string.

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

Convert a duration to a string.

Definition at line 205 of file duration.c.

References duration_struct::days, duration_struct::hours, duration_struct::minutes, duration_struct::months, se_calloc(), se_free(), duration_struct::seconds, duration_struct::weeks, and duration_struct::years.

Referenced by duration2time(), and signconf_print().

time_t duration2time ( duration_type duration)

Convert a duration to a time.

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

Convert a duration to a time.

Definition at line 311 of file duration.c.

References duration_struct::days, duration2string(), duration_struct::hours, duration_struct::minutes, duration_struct::months, se_free(), se_log_warning(), duration_struct::seconds, duration_struct::weeks, and duration_struct::years.

Referenced by worker_perform_task(), zone_add_rr(), and zonedata_sign().

void duration_cleanup ( duration_type duration)

Clean up duration.

Parameters:
[in]durationduration to be cleaned up

Clean up duration.

Definition at line 537 of file duration.c.

References se_free(), and se_log_warning().

Referenced by duration_create_from_string(), and signconf_cleanup().

int duration_compare ( duration_type d1,
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

Compare durations.

Definition at line 69 of file duration.c.

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

Referenced by signconf_compare().

duration_type* duration_create ( void  )

Create a new 'instant' duration.

Returns:
duration_t* the created duration

Durations. Create a new 'instant' duration.

Definition at line 49 of file duration.c.

References duration_struct::days, duration_struct::hours, duration_struct::minutes, duration_struct::months, se_malloc(), duration_struct::seconds, duration_struct::weeks, and duration_struct::years.

Referenced by duration_create_from_string().

duration_type* duration_create_from_string ( const char *  str)
time_t se_rand ( time_t  mod)

Return a random time.

Parameters:
[in]modmodulo
Returns:
time_t random time

Return a random time.

Definition at line 362 of file duration.c.

uint32_t time_datestamp ( time_t  tt,
const char *  format,
char **  str 
)

Return time in datestamp.

Parameters:
[in]tttime
[in]formatstamp format
[out]strstore string
Returns:
uint32_t integer based datestamp.

copycode: This code is based on the EXAMPLE in the strftime manual.

Definition at line 468 of file duration.c.

References se_log_error(), se_strdup(), and time_now().

void time_itoa ( time_t  n,
char *  s 
)

Convert time into string.

Parameters:
[in]ntime
[in]sstring

Convert time into string.

Definition at line 519 of file duration.c.

time_t time_maximum ( time_t  a,
time_t  b 
)

Return the longest time.

Parameters:
[in]aone time
[in]banother time
Returns:
time_t the shortest time

Return the longest time.

Definition at line 351 of file duration.c.

time_t time_minimum ( time_t  a,
time_t  b 
)

Return the shortest time.

Parameters:
[in]aone time
[in]banother time
Returns:
time_t the shortest time

Return the shortest time.

Definition at line 341 of file duration.c.

time_t time_now ( void  )

Return the time since Epoch, measured in seconds. If the timeshift is enabled, return the environment variable.

Returns:
time_t now (or timeshift).

Return the time since Epoch, measured in seconds.

Definition at line 450 of file duration.c.

References timeshift2time().

Referenced by task2str(), task_print(), tasklist_pop_task(), time_datestamp(), worker_perform_task(), worker_start(), zone_recover_from_backup(), zone_update_signconf(), and zonedata_sign().

time_t timeshift2time ( const char *  time)

Convert time iin string format into seconds.

Parameters:
[in]timetime in string format return time_t time in seconds

Convert time in string format into seconds.

Definition at line 431 of file duration.c.

Referenced by time_now().