FreeBSD/contrib/ntp/ntpq/ntpq.c
/*
 * nntohost_col - convert network number to host name in fixed width.
 *		  This routine enforces the showhostnames setting.
 *		  When displaying hostnames longer than the width,
 *		  the first part of the hostname is displayed.  When
 *		  displaying numeric addresses longer than the width,
 *		  Such as IPv6 addresses, the caller decides whether
 *		  the first or last of the numeric address is used.
 */
convert network number to host name in fixed width.
This routine enforces the showhostnames setting.
When displaying hostnames longer than the width,
the first part of the hostname is displayed.  When
displaying numeric addresses longer than the width,
Such as IPv6 addresses, the caller decides whether
the first or last of the numeric address is used.
convert network number to host name in fixed width . This routine enforces the showhostnames setting . When displaying hostnames longer than the width the first part of the hostname is displayed . When displaying numeric addresses longer than the width Such as IPv6 addresses the caller decides whether the first or last of the numeric address is used .
const char *
nntohost_col(
	sockaddr_u *	addr,
	size_t		width,
	int		preserve_lowaddrbits
	)
{
	const char *	out;
	if (!showhostnames || SOCK_UNSPEC(addr)) {
		if (preserve_lowaddrbits)
			out = trunc_left(stoa(addr), width);
		else
			out = trunc_right(stoa(addr), width);
	} else if (ISREFCLOCKADR(addr)) {
		out = refnumtoa(addr);
	} else {
		out = trunc_right(socktohost(addr), width);
	}
	return out;
}
const char * nntohost_col ( sockaddr_u * addr , size_t width , int preserve_lowaddrbits ) { const char * out ; if ( ! showhostnames || SOCK_UNSPEC ( addr ) ) { if ( preserve_lowaddrbits ) out = trunc_left ( stoa ( addr ) , width ) ; else out = trunc_right ( stoa ( addr ) , width ) ; } else if ( ISREFCLOCKADR ( addr ) ) { out = refnumtoa ( addr ) ; } else { out = trunc_right ( socktohost ( addr ) , width ) ; } return out ; }
nntohost_col - convert network number to host name in fixed width.
nntohost_col - convert network number to host name in fixed width .