Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / buftvtots.c
blobf8c25672dcc9642fdcae063d7eff311ae8897aa1
1 /* $NetBSD: buftvtots.c,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
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 */
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"
16 int
17 buftvtots(
18 const char *bufp,
19 l_fp *ts
22 struct timeval tv;
25 * copy to adhere to alignment restrictions
27 memcpy(&tv, bufp, sizeof(tv));
30 * and use it
32 ts->l_ui = tv.tv_sec + (u_long)JAN_1970;
33 if (tv.tv_usec > 999999)
34 return 0;
35 TVUTOTSF(tv.tv_usec, ts->l_uf);
36 return 1;