#include <ncbi.h>
#include <gishlib.h>
#include "blastapp.h"

/* Print all HitLists where the smallest P_val in the list is below a cutoff */
int
print_HSPs(hlp, maxpval, print_hit)
	register HitListPtr	hlp;
	register double	maxpval;
	int		(*print_hit) PROTO((HitListPtr));
{
	long	cnt, noprt, unsatisfactory;

	if (showblast == 0)
		return 0;

	/* For each HitList in the linked list... */
	for (unsatisfactory = cnt = 0; hlp != NULL; hlp = hlp->next) {
		if (hlp->signifhsp->P_val <= maxpval) {
			if (cnt < showblast || showblast < 0) {
				++cnt;
				if ((*print_hit)(hlp) != 0)
					return -1;
			}
		}
		else
			++unsatisfactory;
	}
	noprt = hasHSP - cnt - unsatisfactory;
	if (showblast > 0 && noprt > 0) {
		printf("\n");
		warning("HSPs involving %s database sequences were not reported due to the limiting value of parameter B = %ld.",
				ld2s(noprt),
				showblast);
	}
	return 0;
}
