File:  [MW Coherent from dump] / coherent / d / lib / libc / stdio / fread.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * Standard I/O Library
 * Read nitems of size from file fp
 */

#include <stdio.h>

int
fread(bp, size, nitems, fp)
register char	*bp;
unsigned int	size;
unsigned int	nitems;
register FILE	*fp;
{
	unsigned int	nb = size*nitems;
	register int	c;

	if (fp->_ff&_FUNGOT) {
		*bp++ = (*fp->_gt)(fp);
		nb--;
	}
	if (fp->_bp!=NULL || !(fp->_ff&_FSTBUF))
		for (; nb && (c=getc(fp))!=EOF; nb--)
			*bp++ = c;
	else if ((c=read(fileno(fp), bp, nb)) > 0)
		nb -= c;
	else if (c == 0)
		fp->_ff |= _FEOF;
	else
		fp->_ff |= _FERR;
	return ((size*nitems-nb)/size);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.