ter fetched.  value is a pointer to
the location where the character itself will be saved, and skipflg
determines whether or not white space is skipped.
*/

getchr(value,skipflg)
char *value, skipflg;
{
	char c;
	while (TRUE) if ((c = getattr(*value = *linptr++)) != TRASH &&
			(c != BLANK || skipflg != SKIP)) return c;
}

/*
Function to get a new line of source text from the disk.  Returns 0
if EOF encountered, 1 otherwise.
*/

getlin()
{
	char count, c;
	linptr = linbuf;
	count = 0;
	backflg = FALSE;
	while ((c = getc(source)) != ERROR && (c &= 0x7f) != CPMEOF)
	{
		if (c == '\n')
		{
			*linptr = '\0';
			*--linptr = c;
			linptr = linbuf;
			return 1;
		}
		if (count < LINLEN) *linptr++ = c;
		count++;
	}
	return 0;
}

/*
Function to rewind an input file.  This function is of general use.
It goes as follows:  rewind(iobuf);  The function returns -1 on error,
0 otherwise.
*/

rewind(iobuf)
struct _buf *iobuf;
{
	iobuf -> _nleft = 0;
	return seek(iobuf -> _fdse NOMORE:	flshhbf(0);
				fputs(":0000000000\n",hex);
				if (hex >= LODISK) putc(CPMEOF,hex);
				else if (hex == LST) putc('\f',hex);
				fflush(hex);
				fclose(hex);
	}
}

/*
Function to put a line of intel hex to the appropriate
device and get a new line started.
*/

flshhbf(loadaddr)
unsigned loadaddr;
{
	if (hex == NOFILE) return;
	if (hxbytes != 0)
	{
		puthex2(-(chksum+hxbytes),&hxlnptr);
		*hxlnptr++ = '\n';
		*hxlnptr++ = '\0';
		hxlnptr = hxlnbuf + 1;
		puthex2(hxbytes,&hxlnptr);
		fputs(hxlnbuf,hex);
	}
	hxbytes = 0;
	hxlnptr = hxlnbuf;
	*hxlnptr++ = ':';
	hxlnptr += 2;
	puthex4(loadaddr,&hxlnptr);
	puthex2(0,&hxlnptr);
	chksum = (loadaddr >> 8) + (loadaddr & 0xff);
}

/*
Function to put a 4-digit hex number into an output line.
*/

puthex4(number,lineptr)
unsigned number;
char **lineptr;
{
	puthex2(number>>8,lineptr);
	puthex2(number,lineptr);
}

/*
Function to put a 2-digit hex number into an output line.
*/

puthex2(number,lineptr)
char num