xref: /titanic_51/usr/src/lib/libresolv2/common/bsd/readv.c (revision bb1fad37c75defa7a6ae25f00c1d4b356713b734)
1 #ifndef LINT
2 static const char rcsid[] = "$Id: readv.c,v 1.2 2005/04/27 04:56:11 sra Exp $";
3 #endif
4 
5 #include "port_before.h"
6 
7 #include <sys/types.h>
8 #include <sys/uio.h>
9 #include <sys/stat.h>
10 #include <sys/socket.h>
11 
12 #include "port_after.h"
13 
14 #ifndef NEED_READV
15 int __bindcompat_readv;
16 #else
17 
18 int
19 __readv(fd, vp, vpcount)
20 	int fd;
21 	const struct iovec *vp;
22 	int vpcount;
23 {
24 	int count = 0;
25 
26 	while (vpcount-- > 0) {
27 		int bytes = read(fd, vp->iov_base, vp->iov_len);
28 
29 		if (bytes < 0)
30 			return (-1);
31 		count += bytes;
32 		if (bytes != vp->iov_len)
33 			break;
34 		vp++;
35 	}
36 	return (count);
37 }
38 #endif /* NEED_READV */
39 /*! \file */
40