syslog-ng source
cache.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2018 Balabit
3  * Copyright (c) 1998-2018 Balázs Scheidler
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * As an additional exemption you are allowed to compile & link against the
20  * OpenSSL libraries as published by the OpenSSL project. See the file
21  * COPYING for details.
22  *
23  */
24 
25 #ifndef TIMEUTILS_CACHE_H_INCLUDED
26 #define TIMEUTILS_CACHE_H_INCLUDED
27 
29 #include "timeutils/zoneinfo.h"
30 
31 /* the thread safe variant of the global "timezone" */
32 glong cached_get_system_tzofs(void);
33 
34 /* the thread safe variant of the global "tzname" */
35 const gchar *const *cached_get_system_tznames(void);
36 
37 /* the timezone offset at the specified UTC time */
38 long get_local_timezone_ofs(time_t when);
39 
40 time_t cached_mktime(struct tm *tm);
41 void cached_localtime(time_t *when, struct tm *tm);
42 void cached_gmtime(time_t *when, struct tm *tm);
43 
44 void timeutils_cache_deinit(void);
45 
46 static inline void
47 cached_localtime_wct(time_t *when, WallClockTime *wct)
48 {
49  cached_localtime(when, &wct->tm);
50 }
51 
52 static inline time_t
53 cached_mktime_wct(WallClockTime *wct)
54 {
55  return cached_mktime(&wct->tm);
56 }
57 
58 static inline void
59 cached_gmtime_wct(time_t *when, WallClockTime *wct)
60 {
61  cached_gmtime(when, &wct->tm);
62 }
63 
65 void set_cached_realtime(struct timespec *ts);
66 void get_cached_realtime(struct timespec *ts);
67 time_t get_cached_realtime_sec(void);
68 
69 TimeZoneInfo *cached_get_time_zone_info(const gchar *tz);
70 
72 
73 #endif
time_t cached_mktime(struct tm *tm)
Definition: cache.c:318
void cached_localtime(time_t *when, struct tm *tm)
Definition: cache.c:345
void invalidate_timeutils_cache(void)
Definition: cache.c:238
time_t get_cached_realtime_sec(void)
Definition: cache.c:309
void timeutils_cache_deinit(void)
Definition: cache.c:232
void get_cached_realtime(struct timespec *ts)
Definition: cache.c:301
glong cached_get_system_tzofs(void)
Definition: cache.c:410
void set_cached_realtime(struct timespec *ts)
Definition: cache.c:255
void cached_gmtime(time_t *when, struct tm *tm)
Definition: cache.c:373
long get_local_timezone_ofs(time_t when)
Definition: cache.c:115
void invalidate_cached_realtime(void)
Definition: cache.c:249
const gchar *const * cached_get_system_tznames(void)
Definition: cache.c:417
TimeZoneInfo * cached_get_time_zone_info(const gchar *tz)
Definition: cache.c:401