FreeBSD/contrib/ntp/libntp/statestr.c
/*
 * statustoa - return a descriptive string for a peer status
 */
return a descriptive string for a peer status
return a descriptive string for a peer status
char *
statustoa(
	int type,
	int st
	)
{
	char *	cb;
	char *	cc;
	u_char	pst;
	LIB_GETBUF(cb);
	switch (type) {
	case TYPE_SYS:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s, %s",
			 getcode(CTL_SYS_LI(st), leap_codes),
			 getcode(CTL_SYS_SOURCE(st), sync_codes),
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode(CTL_SYS_EVENT(st), sys_codes));
		break;
	case TYPE_PEER:
		pst = (u_char)CTL_PEER_STATVAL(st);
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s",
			 peer_st_flags(pst),
			 getcode(pst & 0x7, select_codes),
			 getevents(CTL_PEER_NEVNT(st)));
		if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
			cc = cb + strlen(cb);
			snprintf(cc, LIB_BUFLENGTH - (cc - cb), ", %s",
				 getcode(CTL_PEER_EVENT(st),
					 peer_codes));
		}
		break;
	case TYPE_CLOCK:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s",
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode((st) & 0xf, clock_codes));
		break;
	}
	return cb;
}
char * statustoa ( int type , int st ) { char * cb ; char * cc ; u_char pst ; LIB_GETBUF ( cb ) ; switch ( type ) { case TYPE_SYS : snprintf ( cb , LIB_BUFLENGTH , " " , getcode ( CTL_SYS_LI ( st ) , leap_codes ) , getcode ( CTL_SYS_SOURCE ( st ) , sync_codes ) , getevents ( CTL_SYS_NEVNT ( st ) ) , getcode ( CTL_SYS_EVENT ( st ) , sys_codes ) ) ; break ; case TYPE_PEER : pst = ( u_char ) CTL_PEER_STATVAL ( st ) ; snprintf ( cb , LIB_BUFLENGTH , " " , peer_st_flags ( pst ) , getcode ( pst & 0x7 , select_codes ) , getevents ( CTL_PEER_NEVNT ( st ) ) ) ; if ( CTL_PEER_EVENT ( st ) != EVNT_UNSPEC ) { cc = cb + strlen ( cb ) ; snprintf ( cc , LIB_BUFLENGTH - ( cc - cb ) , " " , getcode ( CTL_PEER_EVENT ( st ) , peer_codes ) ) ; } break ; case TYPE_CLOCK : snprintf ( cb , LIB_BUFLENGTH , " " , getevents ( CTL_SYS_NEVNT ( st ) ) , getcode ( ( st ) & 0xf , clock_codes ) ) ; break ; } return cb ; }
statustoa - return a descriptive string for a peer status
statustoa - return a descriptive string for a peer status