1: /*
2: * buftvtots - pull a Unix-format (struct timeval) time stamp out of
3: * an octet stream and convert it to a l_fp time stamp.
4: * This is useful when using the clock line discipline.
5: */
6:
7: #ifdef HAVE_CONFIG_H
8: #include "config.h"
9: #endif
10: #include "ntp_fp.h"
11: #include "ntp_string.h"
12: #include "ntp_unixtime.h"
13:
14: #ifndef SYS_WINNT
15: int
16: buftvtots(
17: const char *bufp,
18: l_fp *ts
19: )
20: {
21: struct timeval tv;
22:
23: /*
24: * copy to adhere to alignment restrictions
25: */
26: memcpy(&tv, bufp, sizeof(tv));
27:
28: /*
29: * and use it
30: */
31: ts->l_ui = tv.tv_sec + (u_long)JAN_1970;
32: if (tv.tv_usec > 999999)
33: return 0;
34: TVUTOTSF(tv.tv_usec, ts->l_uf);
35: return 1;
36: }
37: #else /* SYS_WINNT */
38: /*
39: * Windows doesn't have the tty_clock line discipline, so
40: * don't look for a timestamp where there is none.
41: */
42: int
43: buftvtots(
44: const char *bufp,
45: l_fp *ts
46: )
47: {
48: UNUSED_ARG(bufp);
49: UNUSED_ARG(ts);
50:
51: return 0;
52: }
53: #endif /* SYS_WINNT */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>