]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/ntpd/ntpdtest.cpp
Fix a regression with SA-15:24 patch that prevented NIS from
[FreeBSD/releng/10.2.git] / contrib / ntp / tests / ntpd / ntpdtest.cpp
1 #include "ntpdtest.h"
2
3 /* This file contains various constants that libntp needs to be set
4  *  and that is normally defined in ntpd/ntpq/...
5  */
6
7 u_long current_time = 4; // needed by authkeys. Used only in to calculate lifetime.
8 const char *progname = "ntpdtest";
9
10 time_t ntpdtest::nowtime = 0;
11
12 time_t ntpdtest::timefunc(time_t *ptr)
13 {
14     if (ptr)
15         *ptr = nowtime;
16     return nowtime;
17 }
18
19 void ntpdtest::settime(int y, int m, int d, int H, int M, int S)
20 {
21
22     time_t days(ntpcal_edate_to_eradays(y-1, m-1, d-1) + 1 - DAY_UNIX_STARTS);
23     time_t secs(ntpcal_etime_to_seconds(H, M, S));
24
25     nowtime = days * SECSPERDAY + secs;
26 }
27