FreeBSD/contrib/ntp/ntpd/ntp_leapsec.c
/* ---------------------------------------------------------------------
 * Dump a table in human-readable format. Use 'fprintf' and a FILE
 * pointer if you want to get it printed into a stream.
 */
Dump a table in human-readable format. Use 'fprintf' and a FILE
pointer if you want to get it printed into a stream.
Dump a table in human - readable format . Use ' fprintf ' and a FILE pointer if you want to get it printed into a stream .
void
leapsec_dump(
	const leap_table_t * pt  ,
	leapsec_dumper       func,
	void *               farg)
{
	int             idx;
	vint64          ts;
	struct calendar atb, ttb;
	ntpcal_ntp64_to_date(&ttb, &pt->head.expire);
	(*func)(farg, "leap table (%u entries) expires at %04u-%02u-%02u:\n",
		pt->head.size,
		ttb.year, ttb.month, ttb.monthday);
	idx = pt->head.size;
	while (idx-- != 0) {
		ts = pt->info[idx].ttime;
		ntpcal_ntp64_to_date(&ttb, &ts);
		ts = subv64u32(&ts, pt->info[idx].stime);
		ntpcal_ntp64_to_date(&atb, &ts);
		(*func)(farg, "%04u-%02u-%02u [%c] (%04u-%02u-%02u) - %d\n",
			ttb.year, ttb.month, ttb.monthday,
			"-*"[pt->info[idx].dynls != 0],
			atb.year, atb.month, atb.monthday,
			pt->info[idx].taiof);
	}
}
void leapsec_dump ( const leap_table_t * pt , leapsec_dumper func , void * farg ) { int idx ; vint64 ts ; struct calendar atb , ttb ; ntpcal_ntp64_to_date ( & ttb , & pt -> head . expire ) ; ( * func ) ( farg , " \n " , pt -> head . size , ttb . year , ttb . month , ttb . monthday ) ; idx = pt -> head . size ; while ( idx -- != 0 ) { ts = pt -> info [ idx ] . ttime ; ntpcal_ntp64_to_date ( & ttb , & ts ) ; ts = subv64u32 ( & ts , pt -> info [ idx ] . stime ) ; ntpcal_ntp64_to_date ( & atb , & ts ) ; ( * func ) ( farg , " \n " , ttb . year , ttb . month , ttb . monthday , " " [ pt -> info [ idx ] . dynls != 0 ] , atb . year , atb . month , atb . monthday , pt -> info [ idx ] . taiof ) ; } }
Dump a table in human-readable format.
Dump a table in human - readable format .