xref: /titanic_51/usr/src/lib/libresolv2/common/bsd/readv.c (revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829)
17c478bd9Sstevel@tonic-gate #ifndef LINT
2*9525b14bSRao Shoaib static const char rcsid[] = "$Id: readv.c,v 1.2 2005/04/27 04:56:11 sra Exp $";
37c478bd9Sstevel@tonic-gate #endif
47c478bd9Sstevel@tonic-gate 
57c478bd9Sstevel@tonic-gate #include "port_before.h"
67c478bd9Sstevel@tonic-gate 
77c478bd9Sstevel@tonic-gate #include <sys/types.h>
87c478bd9Sstevel@tonic-gate #include <sys/uio.h>
97c478bd9Sstevel@tonic-gate #include <sys/stat.h>
107c478bd9Sstevel@tonic-gate #include <sys/socket.h>
117c478bd9Sstevel@tonic-gate 
127c478bd9Sstevel@tonic-gate #include "port_after.h"
137c478bd9Sstevel@tonic-gate 
147c478bd9Sstevel@tonic-gate #ifndef NEED_READV
157c478bd9Sstevel@tonic-gate int __bindcompat_readv;
167c478bd9Sstevel@tonic-gate #else
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate int
197c478bd9Sstevel@tonic-gate __readv(fd, vp, vpcount)
207c478bd9Sstevel@tonic-gate 	int fd;
217c478bd9Sstevel@tonic-gate 	const struct iovec *vp;
227c478bd9Sstevel@tonic-gate 	int vpcount;
237c478bd9Sstevel@tonic-gate {
247c478bd9Sstevel@tonic-gate 	int count = 0;
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate 	while (vpcount-- > 0) {
277c478bd9Sstevel@tonic-gate 		int bytes = read(fd, vp->iov_base, vp->iov_len);
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 		if (bytes < 0)
307c478bd9Sstevel@tonic-gate 			return (-1);
317c478bd9Sstevel@tonic-gate 		count += bytes;
327c478bd9Sstevel@tonic-gate 		if (bytes != vp->iov_len)
337c478bd9Sstevel@tonic-gate 			break;
347c478bd9Sstevel@tonic-gate 		vp++;
357c478bd9Sstevel@tonic-gate 	}
367c478bd9Sstevel@tonic-gate 	return (count);
377c478bd9Sstevel@tonic-gate }
387c478bd9Sstevel@tonic-gate #endif /* NEED_READV */
39*9525b14bSRao Shoaib /*! \file */
40