freebsd-dev/contrib/ntp/libntp/buftvtots.c

39 lines
643 B
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* buftvtots - pull a Unix-format (struct timeval) time stamp out of
* an octet stream and convert it to a l_fp time stamp.
* This is useful when using the clock line discipline.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ntp_fp.h"
#include "ntp_string.h"
#include "timevalops.h"
1999-12-09 13:01:21 +00:00
#ifndef SYS_WINNT
1999-12-09 13:01:21 +00:00
int
buftvtots(
const char *bufp,
l_fp *ts
)
{
2001-08-29 14:35:15 +00:00
struct timeval tv;
1999-12-09 13:01:21 +00:00
/*
* copy to adhere to alignment restrictions
*/
memcpy(&tv, bufp, sizeof(tv));
1999-12-09 13:01:21 +00:00
/*
* and use it
*/
if (tv.tv_usec > MICROSECONDS - 1)
return FALSE;
*ts = tval_stamp_to_lfp(tv);
return TRUE;
}
#endif /* !SYS_WINNT */