xref: /netbsd-src/external/bsd/ntp/dist/tests/libntp/test-libntp.c (revision cdfa2a7ef92791ba9db70a584a1d904730e6fb46)
1*cdfa2a7eSchristos /*	$NetBSD: test-libntp.c,v 1.2 2020/05/25 20:47:36 christos Exp $	*/
2067f5680Schristos 
3f17b710fSchristos #include <config.h>
4f17b710fSchristos 
5f17b710fSchristos #include "ntp_stdlib.h"
6f17b710fSchristos #include "ntp_calendar.h"
7f17b710fSchristos 
8f17b710fSchristos #include "test-libntp.h"
9f17b710fSchristos 
10f17b710fSchristos 
11f17b710fSchristos time_t nowtime = 0;
12f17b710fSchristos 
13a6f3f22fSchristos 
14a6f3f22fSchristos time_t
timefunc(time_t * ptr)15a6f3f22fSchristos timefunc(time_t *ptr) {
16f17b710fSchristos     if (ptr)
17f17b710fSchristos 	*ptr = nowtime;
18f17b710fSchristos     return nowtime;
19f17b710fSchristos }
20f17b710fSchristos 
21a6f3f22fSchristos 
22a6f3f22fSchristos void
settime(int y,int m,int d,int H,int M,int S)23a6f3f22fSchristos settime(int y, int m, int d, int H, int M, int S) {
24f17b710fSchristos 
25f17b710fSchristos     time_t days = ntpcal_edate_to_eradays(y-1, m-1, d-1) + 1 - DAY_UNIX_STARTS;
26f17b710fSchristos     time_t secs = ntpcal_etime_to_seconds(H, M, S);
27f17b710fSchristos 
28f17b710fSchristos     nowtime = days * SECSPERDAY + secs;
29f17b710fSchristos }
30