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