File:  [Research Unix] / researchv9 / libc / gen / iread.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:22:00 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

/*
 *	iread - insistent read.  Same usage as read, but will always return
 *	either the exact number of bytes requested, 0, or -1, unless a call
 *	to read gets some data and a subsequent call returns 0.
 */
int
iread (fd, buf, n)
	int fd, n;
	register char *buf;
{
	register int r, offset;

	r = read (fd, buf, n);
	if (r <= 0)
		return r;
	offset = 0;
	while (r != n - offset && r > 0) {
		offset += r;
		r = read (fd, buf + offset, n - offset);
	}
	return r < 0? r: r + offset;
}

unix.superglobalmegacorp.com

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