FreeBSD/contrib/ntp/ntpq/ntpq-subs.c
/*
 * doapeers - print a peer spreadsheet with assocIDs
 */
print a peer spreadsheet with assocIDs
print a peer spreadsheet with assocIDs
static void
doapeers(
	int showall,
	FILE *fp,
	int af
	)
{
	u_int		u;
	char		fullname[LENHOSTNAME];
	sockaddr_u	netnum;
	const char *	name_or_num;
	size_t		sl;
	if (!dogetassoc(fp))
		return;
	for (u = 0; u < numhosts; u++) {
		if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
			name_or_num = nntohost(&netnum);
			sl = strlen(name_or_num);
			maxhostlen = max(maxhostlen, sl);
		}
	}
	if (numhosts > 1)
		fprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
			"server (local)");
	fprintf(fp,
		"     remote       refid   assid  st t when poll reach   delay   offset  jitter\n");
	if (numhosts > 1)
		for (u = 0; u <= maxhostlen; u++)
			fprintf(fp, "=");
	fprintf(fp,
		"==============================================================================\n");
	for (u = 0; u < numassoc; u++) {
		if (!showall &&
		    !(CTL_PEER_STATVAL(assoc_cache[u].status)
		      & (CTL_PST_CONFIG|CTL_PST_REACH))) {
			if (debug)
				fprintf(stderr, "eliding [%d]\n",
					(int)assoc_cache[u].assid);
			continue;
		}
		if (!dogetpeers(apeervarlist, (int)assoc_cache[u].assid,
				fp, af))
			return;
	}
	return;
}
static void doapeers ( int showall , FILE * fp , int af ) { u_int u ; char fullname [ LENHOSTNAME ] ; sockaddr_u netnum ; const char * name_or_num ; size_t sl ; if ( ! dogetassoc ( fp ) ) return ; for ( u = 0 ; u < numhosts ; u ++ ) { if ( getnetnum ( chosts [ u ] . name , & netnum , fullname , af ) ) { name_or_num = nntohost ( & netnum ) ; sl = strlen ( name_or_num ) ; maxhostlen = max ( maxhostlen , sl ) ; } } if ( numhosts > 1 ) fprintf ( fp , " " , ( int ) maxhostlen , ( int ) maxhostlen , " " ) ; fprintf ( fp , " \n " ) ; if ( numhosts > 1 ) for ( u = 0 ; u <= maxhostlen ; u ++ ) fprintf ( fp , " " ) ; fprintf ( fp , " \n " ) ; for ( u = 0 ; u < numassoc ; u ++ ) { if ( ! showall && ! ( CTL_PEER_STATVAL ( assoc_cache [ u ] . status ) & ( CTL_PST_CONFIG | CTL_PST_REACH ) ) ) { if ( debug ) fprintf ( stderr , " \n " , ( int ) assoc_cache [ u ] . assid ) ; continue ; } if ( ! dogetpeers ( apeervarlist , ( int ) assoc_cache [ u ] . assid , fp , af ) ) return ; } return ; }
doapeers - print a peer spreadsheet with assocIDs
doapeers - print a peer spreadsheet with assocIDs