xref: /titanic_50/usr/src/lib/libresolv2/common/bsd/readv.c (revision 0e42dee69ed771bf604dd1789fca9d77b5bbe302)
1 /*
2  * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
3  * All rights reserved.
4  */
5 
6 #ifndef LINT
7 static const char rcsid[] = "$Id: readv.c,v 8.2 1999/10/13 16:39:21 vixie Exp $";
8 #endif
9 
10 
11 #pragma ident	"%Z%%M%	%I%	%E% SMI"
12 
13 #include "port_before.h"
14 
15 #include <sys/types.h>
16 #include <sys/uio.h>
17 #include <sys/stat.h>
18 #include <sys/socket.h>
19 
20 #include "port_after.h"
21 
22 #ifndef NEED_READV
23 int __bindcompat_readv;
24 #else
25 
26 int
27 __readv(fd, vp, vpcount)
28 	int fd;
29 	const struct iovec *vp;
30 	int vpcount;
31 {
32 	int count = 0;
33 
34 	while (vpcount-- > 0) {
35 		int bytes = read(fd, vp->iov_base, vp->iov_len);
36 
37 		if (bytes < 0)
38 			return (-1);
39 		count += bytes;
40 		if (bytes != vp->iov_len)
41 			break;
42 		vp++;
43 	}
44 	return (count);
45 }
46 #endif /* NEED_READV */
47