diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | lib/portability.h | 1 | ||||
-rw-r--r-- | lib/xwrap.c | 13 |
3 files changed, 15 insertions, 0 deletions
@@ -188,6 +188,7 @@ void xsignal(int signal, void *handler); time_t xvali_date(struct tm *tm, char *str); void xparsedate(char *str, time_t *t, unsigned *nano, int endian); char *xgetline(FILE *fp, int *len); +time_t xmktime(struct tm *tm, int utc); // lib.c void verror_msg(char *msg, int err, va_list va); diff --git a/lib/portability.h b/lib/portability.h index acc32fd4..41128958 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -175,6 +175,7 @@ void *memmem(const void *haystack, size_t haystack_length, // Linux headers not listed by POSIX or LSB #include <sys/mount.h> #ifdef __linux__ +#include <linux/rtc.h> #include <sys/statfs.h> #include <sys/swap.h> #include <sys/sysinfo.h> diff --git a/lib/xwrap.c b/lib/xwrap.c index 555fbd5e..5f18f295 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -1077,3 +1077,16 @@ char *xgetline(FILE *fp, int *len) return new; } + +time_t xmktime(struct tm *tm, int utc) +{ + char *old_tz = utc ? xtzset("UTC0") : 0; + time_t result; + + if ((result = mktime(tm)) < 0) error_exit("mktime"); + if (utc) { + free(xtzset(old_tz)); + free(old_tz); + } + return result; +} |