summaryrefslogtreecommitdiff
path: root/src/libstddjb/allreadwrite.c
blob: 19e4c1cad48d2e4982426ae65aee1aa501cc9601 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <skalibs/allreadwrite.h>

size_t allreadwrite (io_func_ref op, int fd, char *buf, size_t len)
{
  size_t written = 0 ;
  while (len)
  {
    ssize_t w = (*op)(fd, buf, len) ;
    if (w <= 0) break ;
    written += w ;
    buf += w ;
    len -= w ;
  }
  return written ;
}