From bb1df8296b9bf90c9a8a30144f32c4eb23937484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 29 Feb 2012 20:58:30 +0100 Subject: [PATCH] Add win32 directory (for compatibility) --- src/win32/compat.hpp | 34 +++++++++++++++++++++++++++ src/win32/gmtime_r.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 src/win32/compat.hpp create mode 100644 src/win32/gmtime_r.cpp diff --git a/src/win32/compat.hpp b/src/win32/compat.hpp new file mode 100644 index 0000000..8457617 --- /dev/null +++ b/src/win32/compat.hpp @@ -0,0 +1,34 @@ +/* + Copyright 2010-2012 Grégory Soutadé + + This file is part of KissCount. + + KissCount is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + KissCount is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with KissCount. If not, see . +*/ + +#ifndef COMPAT_H +#define COMPAT_H + +#ifdef WIN32 + +#include +#include +#include + +struct tm *localtime_r (const time_t *, struct tm *); +struct tm *gmtime_r (const time_t *, struct tm *); + +#endif + +#endif diff --git a/src/win32/gmtime_r.cpp b/src/win32/gmtime_r.cpp new file mode 100644 index 0000000..15f3395 --- /dev/null +++ b/src/win32/gmtime_r.cpp @@ -0,0 +1,52 @@ +/* + Copyright 2010-2012 Grégory Soutadé + + This file is part of KissCount. + + KissCount is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + KissCount is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with KissCount. If not, see . +*/ + + +#ifdef WIN32 + +#include "compat.hpp" + +// From http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html +struct tm * +localtime_r (const time_t *timer, struct tm *result) +{ + struct tm *local_result; + local_result = localtime (timer); + + if (local_result == NULL || result == NULL) + return NULL; + + memcpy (result, local_result, sizeof (result)); + return result; +} + +struct tm * +gmtime_r (const time_t *timer, struct tm *result) +{ + struct tm *local_result; + local_result = gmtime (timer); + + if (local_result == NULL || result == NULL) + return NULL; + + memcpy (result, local_result, sizeof (result)); + return result; +} + +#endif