-/* $OpenBSD: grdc.c,v 1.27 2017/07/13 02:57:52 tb Exp $ */
+/* $OpenBSD: grdc.c,v 1.28 2017/12/11 23:33:44 tb Exp $ */
/*
*
* Copyright 2002 Amos Shapir. Public domain.
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
+#include <time.h>
#include <unistd.h>
#define XLENGTH 58
int i, j, s, k;
int scrol;
int n = 0;
- struct timeval nowtv, endtv;
- struct timespec delay;
+ struct timespec delay, end;
const char *errstr;
long scroldelay = 50000000;
int xbase;
curs_set(0);
sigwinched = 1; /* force initial sizing */
- gettimeofday(&nowtv, NULL);
- TIMEVAL_TO_TIMESPEC(&nowtv, &now);
+ clock_gettime(CLOCK_REALTIME, &now);
if (n)
- endtv.tv_sec = nowtv.tv_sec + n - 1;
+ end.tv_sec = now.tv_sec + n - 1;
do {
if (sigwinched) {
sigwinched = 0;
}
}
if (scrol && k <= 4) {
- gettimeofday(&nowtv, NULL);
- TIMEVAL_TO_TIMESPEC(&nowtv, &now);
+ clock_gettime(CLOCK_REALTIME, &now);
delay.tv_sec = 0;
delay.tv_nsec = 1000000000 - now.tv_nsec
- (4-k) * scroldelay;
}
move(6, 0);
refresh();
- gettimeofday(&nowtv, NULL);
- TIMEVAL_TO_TIMESPEC(&nowtv, &now);
+ clock_gettime(CLOCK_REALTIME, &now);
delay.tv_sec = 0;
delay.tv_nsec = (1000000000 - now.tv_nsec);
/* want scrolling to END on the second */
endwin();
errx(1, "terminated by signal %d", sigtermed);
}
- } while (n == 0 || nowtv.tv_sec < endtv.tv_sec);
+ } while (n == 0 || now.tv_sec < end.tv_sec);
standend();
clear();
refresh();