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

int LIBCALL
print_p(biop, hlp)
	BlastIoPtr	biop;
	BLAST_HitListPtr	hlp;
{
	FILE	*fp;
	unsigned long	id;
	BLAST_HSPPtr	hp;
	BLAST_StrPtr	dbsp;
	int		i;
	register char	*cp, *cpmax;

	fp = biop->fp;

	dbsp = &hlp->str2;
	id = dbsp->id.data.intvalue;

	db_seek(dbfp, id);
	db_get_seq(dbfp, dbsp);

	cp = dbsp->name;
	cpmax = cp + dbsp->namelen;
	while (cp < cpmax && !isspace(*cp))
		++cp;
	while (cp < cpmax && isspace(*cp))
		++cp;
	i = cp - dbsp->name + 1;
	i = MIN(i, 12);
	if (fp != NULL) {
		putc_unlocked('\n', fp);
		putc_unlocked('\n', fp);
		wrap(fp, ">", dbsp->name, dbsp->namelen, 79, i);
		fprintf(fp, "%*sLength = %s\n", i, "", Ltostr((long)dbsp->len,1));
	}

	for (hp = *hlp->hpp; hp != NULL; hp = hp->next) {
		if (hsp_print(fp, hp, nmats == 1) != 0)
			return 1;
	}
	return 0;
}
