FreeBSD/contrib/ntp/ntpq/ntpq-subs.c
/*
 * findassidrange - verify a range of association ID's
 */
verify a range of association ID's
verify a range of association ID ' s
static int
findassidrange(
	u_int32	assid1,
	u_int32	assid2,
	int *	from,
	int *	to,
	FILE *	fp
	)
{
	associd_t	assids[2];
	int		ind[COUNTOF(assids)];
	u_int		i;
	size_t		a;
	if (0 == numassoc)
		dogetassoc(fp);
	assids[0] = checkassocid(assid1);
	if (0 == assids[0])
		return 0;
	assids[1] = checkassocid(assid2);
	if (0 == assids[1])
		return 0;
	for (a = 0; a < COUNTOF(assids); a++) {
		ind[a] = -1;
		for (i = 0; i < numassoc; i++)
			if (assoc_cache[i].assid == assids[a])
				ind[a] = i;
	}
	for (a = 0; a < COUNTOF(assids); a++)
		if (-1 == ind[a]) {
			fprintf(stderr,
				"***Association ID %u not found in list\n",
				assids[a]);
			return 0;
		}
	if (ind[0] < ind[1]) {
		*from = ind[0];
		*to = ind[1];
	} else {
		*to = ind[0];
		*from = ind[1];
	}
	return 1;
}
static int findassidrange ( u_int32 assid1 , u_int32 assid2 , int * from , int * to , FILE * fp ) { associd_t assids [ 2 ] ; int ind [ COUNTOF ( assids ) ] ; u_int i ; size_t a ; if ( 0 == numassoc ) dogetassoc ( fp ) ; assids [ 0 ] = checkassocid ( assid1 ) ; if ( 0 == assids [ 0 ] ) return 0 ; assids [ 1 ] = checkassocid ( assid2 ) ; if ( 0 == assids [ 1 ] ) return 0 ; for ( a = 0 ; a < COUNTOF ( assids ) ; a ++ ) { ind [ a ] = -1 ; for ( i = 0 ; i < numassoc ; i ++ ) if ( assoc_cache [ i ] . assid == assids [ a ] ) ind [ a ] = i ; } for ( a = 0 ; a < COUNTOF ( assids ) ; a ++ ) if ( -1 == ind [ a ] ) { fprintf ( stderr , " \n " , assids [ a ] ) ; return 0 ; } if ( ind [ 0 ] < ind [ 1 ] ) { * from = ind [ 0 ] ; * to = ind [ 1 ] ; } else { * to = ind [ 0 ] ; * from = ind [ 1 ] ; } return 1 ; }
findassidrange - verify a range of association ID's
findassidrange - verify a range of association ID ' s