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