mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
164 lines
3.3 KiB
C
164 lines
3.3 KiB
C
/*
|
|
* Copyright (C) 1998 Internet Software Consortium.
|
|
*
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
#ifndef ISC_TIME_H
|
|
#define ISC_TIME_H 1
|
|
|
|
#include <isc/result.h>
|
|
#include <isc/boolean.h>
|
|
|
|
#include <windows.h>
|
|
|
|
/***
|
|
*** Intervals
|
|
***/
|
|
|
|
/*
|
|
* The contents of this structure are private, and MUST NOT be accessed
|
|
* directly by callers.
|
|
*
|
|
* The contents are exposed only so that callers may avoid dynamic allocation
|
|
* and instead just declare a 'struct isc_interval'.
|
|
*/
|
|
typedef struct isc_interval {
|
|
LONGLONG interval;
|
|
} *isc_interval_t;
|
|
|
|
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:
|
|
*
|
|
* 't' is a valid.
|
|
*
|
|
* nanoseconds < 1000000000
|
|
*/
|
|
|
|
isc_boolean_t
|
|
isc_interval_iszero(isc_interval_t i);
|
|
/*
|
|
* Returns ISC_TRUE iff. 'i' is the zero interval.
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't' is a valid.
|
|
*
|
|
*/
|
|
|
|
/***
|
|
*** Absolute Times
|
|
***/
|
|
|
|
/*
|
|
* The contents of this structure are private, and MUST NOT be accessed
|
|
* directly by callers.
|
|
*
|
|
* The contents are exposed only so that callers may avoid dynamic allocation
|
|
* and instead just declare a 'struct isc_time'.
|
|
*/
|
|
|
|
typedef struct isc_time {
|
|
FILETIME absolute;
|
|
} *isc_time_t;
|
|
|
|
void
|
|
isc_time_settoepoch(isc_time_t t);
|
|
/*
|
|
* Set 't' to the time of the epoch.
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't' is a valid.
|
|
*
|
|
*/
|
|
|
|
isc_boolean_t
|
|
isc_time_isepoch(isc_time_t t);
|
|
/*
|
|
* Returns ISC_TRUE iff. 't' is the epoch ("time zero").
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't' is a valid.
|
|
*
|
|
*/
|
|
|
|
isc_result_t
|
|
isc_time_get(isc_time_t t);
|
|
/*
|
|
* Set 't' to the current absolute time.
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't' is a valid pointer.
|
|
*
|
|
* Returns:
|
|
*
|
|
* Success
|
|
* Unexpected error
|
|
*/
|
|
|
|
int
|
|
isc_time_compare(isc_time_t t1, isc_time_t t2);
|
|
/*
|
|
* Compare the times referenced by 't1' and 't2'
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't1' and 't2' are a valid.
|
|
*
|
|
* Returns:
|
|
*
|
|
* -1 t1 < t2 (comparing times, not pointers)
|
|
* 0 t1 = t2
|
|
* 1 t1 > t2
|
|
*/
|
|
|
|
void
|
|
isc_time_add(isc_time_t t, isc_interval_t i, isc_time_t result);
|
|
/*
|
|
* Add 'i' to 't', storing the result in 'result'.
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't', 'i', and 'result' are valid.
|
|
*/
|
|
|
|
void
|
|
isc_time_subtract(isc_time_t t, isc_interval_t t2, isc_time_t result);
|
|
/*
|
|
* Subtract 'i' from 't', storing the result in 'result'.
|
|
*
|
|
* Requires:
|
|
*
|
|
* 't', 'i', and 'result' are valid.
|
|
*
|
|
* t >= epoch + i (comparing times, not pointers)
|
|
*/
|
|
|
|
/***
|
|
*** Win32 Only
|
|
***/
|
|
|
|
unsigned int isc_time_millidiff(isc_time_t t1, isc_time_t t2);
|
|
|
|
#endif /* ISC_TIME_H */
|