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

#include <errno.h>
#include <skalibs/allreadwrite.h>

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