#include <config.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <syslog.h>
#include <time.h>
#include <sys/time.h>
#include <isc/log.h>
#include <isc/print.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/tm.h>
#include <isc/util.h>
Go to the source code of this file.
Defines | |
#define | NS_PER_S 1000000000 |
Nanoseconds per second. | |
#define | NS_PER_US 1000 |
Nanoseconds per microsecond. | |
#define | US_PER_S 1000000 |
Microseconds per second. | |
#define | ISC_FIX_TV_USEC 1 |
Functions | |
static void | fix_tv_usec (struct timeval *tv) |
void | isc_interval_set (isc_interval_t *i, unsigned int seconds, unsigned int nanoseconds) |
Set 'i' to a value representing an interval of 'seconds' seconds and 'nanoseconds' nanoseconds, suitable for use in isc_time_add() and isc_time_subtract(). | |
isc_boolean_t | isc_interval_iszero (const isc_interval_t *i) |
Returns ISC_TRUE iff. 'i' is the zero interval. | |
void | isc_time_set (isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) |
Set 't' to a value which represents the given number of seconds and nanoseconds since 00:00:00 January 1, 1970, UTC. | |
void | isc_time_settoepoch (isc_time_t *t) |
Set 't' to the time of the epoch. | |
isc_boolean_t | isc_time_isepoch (const isc_time_t *t) |
Returns ISC_TRUE iff. 't' is the epoch ("time zero"). | |
isc_result_t | isc_time_now (isc_time_t *t) |
Set 't' to the current absolute time. | |
isc_result_t | isc_time_nowplusinterval (isc_time_t *t, const isc_interval_t *i) |
Set *t to the current absolute time + i. | |
int | isc_time_compare (const isc_time_t *t1, const isc_time_t *t2) |
Compare the times referenced by 't1' and 't2'. | |
isc_result_t | isc_time_add (const isc_time_t *t, const isc_interval_t *i, isc_time_t *result) |
Add 'i' to 't', storing the result in 'result'. | |
isc_result_t | isc_time_subtract (const isc_time_t *t, const isc_interval_t *i, isc_time_t *result) |
Subtract 'i' from 't', storing the result in 'result'. | |
isc_uint64_t | isc_time_microdiff (const isc_time_t *t1, const isc_time_t *t2) |
Find the difference in microseconds between time t1 and time t2. t2 is the subtrahend of t1; ie, difference = t1 - t2. | |
isc_uint32_t | isc_time_seconds (const isc_time_t *t) |
Return the number of seconds since the epoch stored in a time structure. | |
isc_result_t | isc_time_secondsastimet (const isc_time_t *t, time_t *secondsp) |
Ensure the number of seconds in an isc_time_t is representable by a time_t. | |
isc_uint32_t | isc_time_nanoseconds (const isc_time_t *t) |
Return the number of nanoseconds stored in a time structure. | |
void | isc_time_formattimestamp (const isc_time_t *t, char *buf, unsigned int len) |
Format the time 't' into the buffer 'buf' of length 'len', using a format like "30-Aug-2000 04:06:47.997" and the local time zone. If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated. | |
void | isc_time_formathttptimestamp (const isc_time_t *t, char *buf, unsigned int len) |
Format the time 't' into the buffer 'buf' of length 'len', using a format like "Mon, 30 Aug 2000 04:06:47 GMT" If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated. | |
isc_result_t | isc_time_parsehttptimestamp (char *buf, isc_time_t *t) |
Parse the time in 'input' into the isc_time_t pointed to by 't', expecting a format like "Mon, 30 Aug 2000 04:06:47 GMT". | |
void | isc_time_formatISO8601 (const isc_time_t *t, char *buf, unsigned int len) |
Format the time 't' into the buffer 'buf' of length 'len', using the ISO8601 format: "yyyy-mm-ddThh:mm:ssZ" If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated. | |
Variables | |
static const isc_interval_t | zero_interval = { 0, 0 } |
Intervals. | |
const isc_interval_t *const | isc_interval_zero = &zero_interval |
static const isc_time_t | epoch = { 0, 0 } |
const isc_time_t *const | isc_time_epoch = &epoch |
Definition in file time.c.
#define NS_PER_S 1000000000 |
Nanoseconds per second.
Definition at line 40 of file time.c.
Referenced by isc_interval_iszero(), isc_interval_set(), isc_time_add(), isc_time_compare(), isc_time_isepoch(), isc_time_microdiff(), isc_time_nanoseconds(), isc_time_nowplusinterval(), isc_time_seconds(), isc_time_secondsastimet(), isc_time_set(), and isc_time_subtract().
#define NS_PER_US 1000 |
Nanoseconds per microsecond.
Definition at line 41 of file time.c.
Referenced by isc_time_microdiff(), isc_time_now(), and isc_time_nowplusinterval().
static void fix_tv_usec | ( | struct timeval * | tv | ) | [inline, static] |
void isc_interval_set | ( | isc_interval_t * | i, | |
unsigned int | seconds, | |||
unsigned int | nanoseconds | |||
) |
Set 'i' to a value representing an interval of 'seconds' seconds and 'nanoseconds' nanoseconds, suitable for use in isc_time_add() and isc_time_subtract().
Requires:
Definition at line 89 of file time.c.
References isc_interval::nanoseconds, NS_PER_S, REQUIRE, and isc_interval::seconds.
Referenced by bringup_timer(), dns_acache_setcleaninginterval(), dns_cache_setcleaninginterval(), dns_timer_setidle(), dns_zone_refresh(), fctx_create(), fctx_getaddresses(), fctx_sendevents(), fctx_setretryinterval(), isc_log_doit(), isc_ratelimiter_create(), load_configuration(), newconnection(), ns_client_error(), ns_client_send(), ns_client_settimeout(), recv_done(), resquery_connected(), schedule(), set_timer(), setmodtime(), setrl(), settimer(), stub_callback(), zone_nsec3chain(), zone_resigninc(), and zone_sign().
isc_boolean_t isc_interval_iszero | ( | const isc_interval_t * | i | ) |
Returns ISC_TRUE iff. 'i' is the zero interval.
Requires:
Definition at line 100 of file time.c.
References INSIST, ISC_FALSE, ISC_TRUE, isc_interval::nanoseconds, NS_PER_S, REQUIRE, and isc_interval::seconds.
Referenced by isc__timer_create(), and isc__timer_reset().
void isc_time_set | ( | isc_time_t * | t, | |
unsigned int | seconds, | |||
unsigned int | nanoseconds | |||
) |
Set 't' to a value which represents the given number of seconds and nanoseconds since 00:00:00 January 1, 1970, UTC.
Notes:
isc_time_settoepoch(t); isc_interval_set(i, seconds, nanoseconds); isc_time_add(t, i, t); *
Definition at line 119 of file time.c.
References isc_time::nanoseconds, NS_PER_S, REQUIRE, and isc_time::seconds.
Referenced by client_request(), dns_ntatable_totext(), isc_file_getmodtime(), isc_time_parsehttptimestamp(), mkey_dumpzone(), ns_server_nta(), ns_server_zonestatus(), set_key_expiry_warning(), set_resigntime(), and totext_keydata().
void isc_time_settoepoch | ( | isc_time_t * | t | ) |
Set 't' to the time of the epoch.
Notes:
Definition at line 128 of file time.c.
References isc_time::nanoseconds, REQUIRE, and isc_time::seconds.
Referenced by dns_badcache_add(), dns_badcache_flushname(), dns_badcache_flushtree(), dns_zone_create(), dump_done(), isc__timer_create(), isc__timer_reset(), isc__timermgr_create(), ns_server_zonestatus(), set_key_expiry_warning(), set_resigntime(), sync_keyzone(), was_dumping(), zone_dump(), zone_nsec3chain(), zone_refreshkeys(), zone_registerinclude(), zone_settimer(), and zone_sign().
isc_boolean_t isc_time_isepoch | ( | const isc_time_t * | t | ) |
Returns ISC_TRUE iff. 't' is the epoch ("time zero").
Requires:
Definition at line 136 of file time.c.
References INSIST, ISC_FALSE, ISC_TRUE, isc_time::nanoseconds, NS_PER_S, REQUIRE, and isc_time::seconds.
Referenced by dispatch(), isc__timer_create(), isc__timer_reset(), mkey_status(), ns_server_zonestatus(), schedule(), zone_addnsec3chain(), zone_load(), zone_maintenance(), zone_needdump(), and zone_settimer().
isc_result_t isc_time_now | ( | isc_time_t * | t | ) |
Set 't' to the current absolute time.
Requires:
Definition at line 148 of file time.c.
References fix_tv_usec(), isc__strerror(), ISC_R_RANGE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, isc_time::nanoseconds, NS_PER_US, REQUIRE, isc_time::seconds, UNEXPECTED_ERROR, and US_PER_S.
Referenced by adjust_quantum(), ATF_TC_BODY(), dns_badcache_add(), dns_badcache_flushname(), dns_badcache_flushtree(), dumptostreaminc(), free_rbtdb(), incremental_cleaning_action(), isc_httpd_recvdone(), isc_httpdmgr_addurl2(), load_configuration(), maybe_free(), ns_server_changezone(), ns_server_delzone(), setup(), view_find(), xfrin_create(), and xfrin_send_request().
isc_result_t isc_time_nowplusinterval | ( | isc_time_t * | t, | |
const isc_interval_t * | i | |||
) |
Set *t to the current absolute time + i.
Note:
isc_time_now(t); isc_time_add(t, i, t); *
Requires:
Definition at line 189 of file time.c.
References fix_tv_usec(), INSIST, isc__strerror(), ISC_R_RANGE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, isc_time::nanoseconds, isc_interval::nanoseconds, NS_PER_S, NS_PER_US, REQUIRE, isc_time::seconds, isc_interval::seconds, UNEXPECTED_ERROR, and US_PER_S.
Referenced by dns_timer_setidle(), dns_zone_refresh(), fctx_create(), fctx_getaddresses(), ns_client_error(), set_timer(), zone_nsec3chain(), zone_resigninc(), and zone_sign().
int isc_time_compare | ( | const isc_time_t * | t1, | |
const isc_time_t * | t2 | |||
) |
Compare the times referenced by 't1' and 't2'.
Requires:
Definition at line 239 of file time.c.
References INSIST, isc_time::nanoseconds, NS_PER_S, REQUIRE, and isc_time::seconds.
Referenced by badcache_resize(), dispatch(), dns_badcache_add(), dns_badcache_find(), dns_badcache_flushname(), dns_badcache_flushtree(), dns_badcache_print(), fctx_timeout(), isc_log_doit(), refresh_callback(), schedule(), set_refreshkeytimer(), sooner(), zone_maintenance(), zone_needdump(), zone_postload(), zone_settimer(), and zone_touched().
isc_result_t isc_time_add | ( | const isc_time_t * | t, | |
const isc_interval_t * | i, | |||
isc_time_t * | result | |||
) |
Add 'i' to 't', storing the result in 'result'.
Requires:
Definition at line 255 of file time.c.
References INSIST, ISC_R_RANGE, ISC_R_SUCCESS, isc_interval::nanoseconds, isc_time::nanoseconds, NS_PER_S, REQUIRE, isc_interval::seconds, and isc_time::seconds.
Referenced by isc__timer_create(), isc__timer_reset(), isc__timer_touch(), and schedule().
isc_result_t isc_time_subtract | ( | const isc_time_t * | t, | |
const isc_interval_t * | i, | |||
isc_time_t * | result | |||
) |
Subtract 'i' from 't', storing the result in 'result'.
Requires:
Definition at line 281 of file time.c.
References INSIST, ISC_R_RANGE, ISC_R_SUCCESS, isc_interval::nanoseconds, isc_time::nanoseconds, NS_PER_S, REQUIRE, isc_interval::seconds, and isc_time::seconds.
Referenced by isc_log_doit(), and setmodtime().
isc_uint64_t isc_time_microdiff | ( | const isc_time_t * | t1, | |
const isc_time_t * | t2 | |||
) |
Find the difference in microseconds between time t1 and time t2. t2 is the subtrahend of t1; ie, difference = t1 - t2.
Requires:
Definition at line 305 of file time.c.
References INSIST, isc_time::nanoseconds, NS_PER_S, NS_PER_US, REQUIRE, and isc_time::seconds.
Referenced by adjust_quantum(), dns_badcache_print(), dumptostreaminc(), evloop(), fctx_cancelquery(), fctx_sendevents(), maybe_free(), print_stats(), received(), and say_message().
isc_uint32_t isc_time_seconds | ( | const isc_time_t * | t | ) |
Return the number of seconds since the epoch stored in a time structure.
Requires:
Definition at line 328 of file time.c.
References INSIST, isc_time::nanoseconds, NS_PER_S, REQUIRE, and isc_time::seconds.
Referenced by ATF_TC_BODY(), debug(), isc_file_settime(), ns_xfr_start(), query_find(), resquery_send(), schedule(), and zone_maintenance().
isc_result_t isc_time_secondsastimet | ( | const isc_time_t * | t, | |
time_t * | secondsp | |||
) |
Ensure the number of seconds in an isc_time_t is representable by a time_t.
Notes:
Definition at line 336 of file time.c.
References INSIST, ISC_R_RANGE, ISC_R_SUCCESS, isc_time::nanoseconds, NS_PER_S, REQUIRE, and isc_time::seconds.
Referenced by isc_condition_waituntil(), and render_xsl().
isc_uint32_t isc_time_nanoseconds | ( | const isc_time_t * | t | ) |
Return the number of nanoseconds stored in a time structure.
Notes:
Definition at line 373 of file time.c.
References ENSURE, isc_time::nanoseconds, NS_PER_S, and REQUIRE.
Referenced by debug(), isc_condition_waituntil(), isc_file_settime(), and kbdget().
void isc_time_formattimestamp | ( | const isc_time_t * | t, | |
char * | buf, | |||
unsigned int | len | |||
) |
Format the time 't' into the buffer 'buf' of length 'len', using a format like "30-Aug-2000 04:06:47.997" and the local time zone. If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated.
Requires:
Definition at line 382 of file time.c.
References INSIST, isc_time::nanoseconds, now, REQUIRE, and isc_time::seconds.
Referenced by dns_ntatable_totext(), isc_log_doit(), ns_server_dumpsecroots(), ns_server_nta(), set_key_expiry_warning(), set_refreshkeytimer(), and zone_refreshkeys().
void isc_time_formathttptimestamp | ( | const isc_time_t * | t, | |
char * | buf, | |||
unsigned int | len | |||
) |
Format the time 't' into the buffer 'buf' of length 'len', using a format like "Mon, 30 Aug 2000 04:06:47 GMT" If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated.
Requires:
Definition at line 401 of file time.c.
References INSIST, now, REQUIRE, and isc_time::seconds.
Referenced by ATF_TC_BODY(), isc_httpd_recvdone(), mkey_dumpzone(), mkey_status(), ns_server_status(), ns_server_zonestatus(), and totext_keydata().
isc_result_t isc_time_parsehttptimestamp | ( | char * | input, | |
isc_time_t * | t | |||
) |
Parse the time in 'input' into the isc_time_t pointed to by 't', expecting a format like "Mon, 30 Aug 2000 04:06:47 GMT".
Requires:
Definition at line 416 of file time.c.
References ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_time_set(), isc_tm_strptime(), isc_tm_timegm(), and REQUIRE.
Referenced by ATF_TC_BODY(), ATF_TP_ADD_TCS(), and render_xsl().
void isc_time_formatISO8601 | ( | const isc_time_t * | t, | |
char * | buf, | |||
unsigned int | len | |||
) |
Format the time 't' into the buffer 'buf' of length 'len', using the ISO8601 format: "yyyy-mm-ddThh:mm:ssZ" If the text does not fit in the buffer, the result is indeterminate, but is always guaranteed to be null terminated.
Requires:
Definition at line 434 of file time.c.
References INSIST, now, REQUIRE, and isc_time::seconds.
const isc_interval_t zero_interval = { 0, 0 } [static] |
const isc_interval_t* const isc_interval_zero = &zero_interval |
const isc_time_t epoch = { 0, 0 } [static] |
const isc_time_t* const isc_time_epoch = &epoch |