2 * $Id: duration.h 4341 2011-01-31 15:21:09Z matthijs $
4 * Copyright (c) 2009 NLNet Labs. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
31 * This file is copied from the OpenDNSSEC source repository
32 * and only slightly adapted to make it fit.
40 #ifndef LDNS_DURATION_H
41 #define LDNS_DURATION_H
50 typedef struct ldns_duration_struct ldns_duration_type;
51 struct ldns_duration_struct
63 * Create a new 'instant' duration.
64 * \return ldns_duration_type* created duration
67 ldns_duration_type* ldns_duration_create(void);
71 * \param[in] d1 one duration
72 * \param[in] d2 another duration
73 * \return int 0 if equal, -1 if d1 < d2, 1 if d2 < d1
76 int ldns_duration_compare(const ldns_duration_type* d1, const ldns_duration_type* d2);
79 * Create a duration from string.
80 * \param[in] str string-format duration
81 * \return ldns_duration_type* created duration
84 ldns_duration_type* ldns_duration_create_from_string(const char* str);
87 * Convert a duration to a string.
88 * \param[in] duration duration to be converted
89 * \return char* string-format duration
92 char* ldns_duration2string(const ldns_duration_type* duration);
95 * Convert a duration to a time.
96 * \param[in] duration duration to be converted
97 * \return time_t time-format duration
100 time_t ldns_duration2time(const ldns_duration_type* duration);
104 * \param[in] duration duration to be cleaned up
107 void ldns_duration_cleanup(ldns_duration_type* duration);
109 #endif /* LDNS_DURATION_H */