ldns  1.7.0
duration.h
Go to the documentation of this file.
1 /*
2  * $Id: duration.h 4341 2011-01-31 15:21:09Z matthijs $
3  *
4  * Copyright (c) 2009 NLNet Labs. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
40 #ifndef LDNS_DURATION_H
41 #define LDNS_DURATION_H
42 
43 #if defined(_AIX51) && !defined(_AIX52)
44 #include <inttypes.h>
45 #else
46 #include <stdint.h>
47 #endif
48 #include <time.h>
49 
56 {
57  time_t years;
58  time_t months;
59  time_t weeks;
60  time_t days;
61  time_t hours;
62  time_t minutes;
63  time_t seconds;
64 };
65 
72 
81 
89 
96 char* ldns_duration2string(const ldns_duration_type* duration);
97 
104 time_t ldns_duration2time(const ldns_duration_type* duration);
105 
112 
113 #endif /* LDNS_DURATION_H */
time_t ldns_duration2time(const ldns_duration_type *duration)
Convert a duration to a time.
Definition: duration.c:319
char * ldns_duration2string(const ldns_duration_type *duration)
Convert a duration to a string.
Definition: duration.c:216
void ldns_duration_cleanup(ldns_duration_type *duration)
Clean up duration.
Definition: duration.c:347
ldns_duration_type * ldns_duration_create_from_string(const char *str)
Create a duration from string.
Definition: duration.c:118
ldns_duration_type * ldns_duration_create(void)
Create a new 'instant' duration.
Definition: duration.c:54
int ldns_duration_compare(const ldns_duration_type *d1, const ldns_duration_type *d2)
Compare durations.
Definition: duration.c:78