File: readn.c

package info (click to toggle)
drawterm 20091003-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,920 kB
  • ctags: 5,505
  • sloc: ansic: 55,149; makefile: 566; asm: 20
file content (22 lines) | stat: -rw-r--r-- 234 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <u.h>
#include <libc.h>

long
readn(int f, void *av, long n)
{
	char *a;
	long m, t;

	a = av;
	t = 0;
	while(t < n){
		m = read(f, a+t, n-t);
		if(m <= 0){
			if(t == 0)
				return m;
			break;
		}
		t += m;
	}
	return t;
}