aboutsummaryrefslogtreecommitdiffstats
path: root/src/radharc.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-03 02:15:31 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-03 02:15:31 +0100
commitab80d705ed719244d6bee81a02b596061d90323f (patch)
tree0c2666b1cbc61b67db31d902a1d20e73bef223a9 /src/radharc.c
parenton -l (diff)
downloadradharc-ab80d705ed719244d6bee81a02b596061d90323f.tar.gz
radharc-ab80d705ed719244d6bee81a02b596061d90323f.tar.bz2
radharc-ab80d705ed719244d6bee81a02b596061d90323f.tar.xz
in case of time-travel
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/radharc.c')
-rw-r--r--src/radharc.c25
1 files changed, 25 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+
+
+
+/**
+ * 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;