skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

allreadwritev.c (486B)


      1 /* ISC license. */
      2 
      3 #include <sys/uio.h>
      4 #include <skalibs/siovec.h>
      5 #include <skalibs/allreadwrite.h>
      6 
      7 size_t allreadwritev (iov_func_ref op, int fd, struct iovec const *v, unsigned int vlen)
      8 {
      9   size_t written = 0 ;
     10   struct iovec vv[vlen ? vlen : 1] ;
     11   unsigned int i = vlen ;
     12   while (i--) vv[i] = v[i] ;
     13   while (siovec_len(vv, vlen))
     14   {
     15     ssize_t w = (*op)(fd, vv, vlen) ;
     16     if (w <= 0) break ;
     17     w = siovec_seek(vv, vlen, w) ;
     18     written += w ;
     19   }
     20   return written ;
     21 }