buftvtots.c revision 290001
1202719Sgabor/* 2202719Sgabor * buftvtots - pull a Unix-format (struct timeval) time stamp out of 3202719Sgabor * an octet stream and convert it to a l_fp time stamp. 4202719Sgabor * This is useful when using the clock line discipline. 5202719Sgabor */ 6202719Sgabor 7202719Sgabor#ifdef HAVE_CONFIG_H 8202719Sgabor#include "config.h" 9202719Sgabor#endif 10202719Sgabor#include "ntp_fp.h" 11202719Sgabor#include "ntp_string.h" 12202719Sgabor#include "timevalops.h" 13202719Sgabor 14202719Sgabor#ifndef SYS_WINNT 15202719Sgaborint 16202719Sgaborbuftvtots( 17202719Sgabor const char *bufp, 18202719Sgabor l_fp *ts 19202719Sgabor ) 20202719Sgabor{ 21202719Sgabor struct timeval tv; 22202719Sgabor 23202719Sgabor /* 24202719Sgabor * copy to adhere to alignment restrictions 25202719Sgabor */ 26202719Sgabor memcpy(&tv, bufp, sizeof(tv)); 27202719Sgabor 28202719Sgabor /* 29202719Sgabor * and use it 30202719Sgabor */ 31202719Sgabor if (tv.tv_usec > MICROSECONDS - 1) 32202719Sgabor return FALSE; 33202719Sgabor 34202719Sgabor *ts = tval_stamp_to_lfp(tv); 35202719Sgabor 36202719Sgabor return TRUE; 37202719Sgabor} 38202719Sgabor#endif /* !SYS_WINNT */ 39202719Sgabor