/*
	getedit

	Read next line from stdio file, until a non-comment line is encountered.
	Then strip off leading and trailing white space before returning.

	Return values are 0 on successful read of another line,
	EOF(-1) on error or end of file.
*/
#include <ncbi.h>
#include <gishlib.h>

#define COMMENTCHAR '#'

int LIBCALL
getedit(fp, buf, buflen, nlines)
	register FILE	*fp;
	register CharPtr	buf;
	register int	buflen;
	register int	*nlines;
{
	register CharPtr	cp;

	if (buf == NULL || buflen <= 0)
		return EOF;

	do {
		do {
			if (fgets(buf, buflen, fp) == NULL)
				return EOF;
			++*nlines;
		} while (buf[0] == COMMENTCHAR);

		cp = str_chr(buf, COMMENTCHAR);
		if (cp != NULL)
			*cp = NULLB;

		str_trim(buf, " \t\n\r");
	} while (buf[0] == NULLB);
	return 0;
}
