xref: /titanic_44/usr/src/lib/libresolv2/common/bsd/readv.c (revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829)
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
__readv(fd,vp,vpcount)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