From ab80d705ed719244d6bee81a02b596061d90323f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 Jan 2016 02:15:31 +0100 Subject: in case of time-travel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/radharc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/radharc.c') diff --git a/src/radharc.c b/src/radharc.c index 7b5f1e5..2c5e8c6 100644 --- a/src/radharc.c +++ b/src/radharc.c @@ -20,6 +20,30 @@ * DEALINGS IN THE SOFTWARE. */ #include "settings.h" +#include +#include + + + +/** + * Exit if time the is before year 0 in J2000. + */ +#if defined(TIMETRAVELLER) +static void +check_timetravel(const char *argv0) +{ + struct timespec now; + if (clock_gettime(CLOCK_REALTIME, &now)) + perror(argv0 ? argv0 : "radharc"), exit(1); + if (now.tv_nsec < (time_t)946728000L) + fprintf(stderr, "We have detected that you are a time-traveller" + "(or your clock is not configured correctly.)" + "Please recompile with -DTIMETRAVELLER" + "(or correct your clock.)"), exit(1); +} +#else +# define check_timetravel(_) /* do nothing */ +#endif @@ -28,6 +52,7 @@ main(int argc, char *argv[]) { struct settings settings; + check_timetravel(*argv); parse_command_line(argc, argv, &settings); return 0; -- cgit v1.2.3-70-g09d2