DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦d6f933699⟧ TextFile

    Length: 543 (0x21f)
    Types: TextFile
    Notes: UNIX file
    Names: »fread.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libc/stdio/fread.c« 

TextFile

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

#include <stdio.h>

int
fread(bp, size, nitems, fp)
register char	*bp;
int	size;
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);
}