OpenDNSSEC-signer  1.4.1
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 
34 #ifndef UTIL_DURATION_H
35 #define UTIL_DURATION_H
36 
37 #include "config.h"
38 #include "shared/allocator.h"
39 
40 #include <stdint.h>
41 #include <time.h>
42 
49 {
51  time_t years;
52  time_t months;
53  time_t weeks;
54  time_t days;
55  time_t hours;
56  time_t minutes;
57  time_t seconds;
58 };
59 
66 
75 
83 
90 char* duration2string(duration_type* duration);
91 
98 time_t duration2time(duration_type* duration);
99 
106 time_t ods_rand(time_t mod);
107 
115 time_t time_minimum(time_t a, time_t b);
116 
124 time_t time_maximum(time_t a, time_t b);
125 
132 void time_itoa(time_t n, char* s);
133 
142 uint32_t time_datestamp(time_t tt, const char* format, char** str);
143 
150 time_t time_now(void);
151 
157 void duration_cleanup(duration_type* duration);
158 
159 #endif /* UTIL_DURATION_H */
time_t hours
Definition: duration.h:55
uint32_t time_datestamp(time_t tt, const char *format, char **str)
Definition: duration.c:525
duration_type * duration_create(void)
Definition: duration.c:51
time_t minutes
Definition: duration.h:56
time_t seconds
Definition: duration.h:57
time_t years
Definition: duration.h:51
time_t weeks
Definition: duration.h:53
time_t months
Definition: duration.h:52
void duration_cleanup(duration_type *duration)
Definition: duration.c:594
time_t time_maximum(time_t a, time_t b)
Definition: duration.c:405
char * duration2string(duration_type *duration)
Definition: duration.c:229
time_t duration2time(duration_type *duration)
Definition: duration.c:365
int duration_compare(duration_type *d1, duration_type *d2)
Definition: duration.c:85
void time_itoa(time_t n, char *s)
Definition: duration.c:576
allocator_type * allocator
Definition: duration.h:50
duration_type * duration_create_from_string(const char *str)
Definition: duration.c:125
time_t ods_rand(time_t mod)
Definition: duration.c:416
time_t time_minimum(time_t a, time_t b)
Definition: duration.c:395
time_t days
Definition: duration.h:54
time_t time_now(void)
Definition: duration.c:507