summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-31 20:06:45 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-31 21:43:23 +0100
commit10a264ec3d189ba0fc00e4c6f7b0e7e4a8043aff (patch)
treef6c260517176021690268a8e88d9bb4c5a409d6c /common.c
parent2ec6258ff38747b72f55a0d19370dd5841e3be02 (diff)
downloadxK-10a264ec3d189ba0fc00e4c6f7b0e7e4a8043aff.tar.gz
xK-10a264ec3d189ba0fc00e4c6f7b0e7e4a8043aff.tar.xz
xK-10a264ec3d189ba0fc00e4c6f7b0e7e4a8043aff.zip
kike: add support for IRCv3.2 server-time
Diffstat (limited to 'common.c')
-rw-r--r--common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common.c b/common.c
index a92bae4..7880dee 100644
--- a/common.c
+++ b/common.c
@@ -52,6 +52,21 @@ str_vector_find (const struct str_vector *v, const char *s)
return -1;
}
+static time_t
+unixtime_msec (long *msec)
+{
+#ifdef _POSIX_TIMERS
+ struct timespec tp;
+ hard_assert (clock_gettime (CLOCK_REALTIME, &tp) != -1);
+ *msec = tp.tv_nsec / 1000000;
+#else // ! _POSIX_TIMERS
+ struct timeval tp;
+ hard_assert (gettimeofday (&tp, NULL) != -1);
+ *msec = tp.tv_usec / 1000;
+#endif // ! _POSIX_TIMERS
+ return tp.tv_sec;
+}
+
/// This differs from the non-unique version in that we expect the filename
/// to be something like a pattern for mkstemp(), so the resulting path can
/// reside in a system-wide directory with no risk of a conflict.