Import ezmlm 0.53
[ezmlm] / slurpclose.c
CommitLineData
5b62e993
MW
1#include "stralloc.h"
2#include "readwrite.h"
3#include "slurpclose.h"
4#include "error.h"
5
6int slurpclose(fd,sa,bufsize)
7int fd;
8stralloc *sa;
9int bufsize;
10{
11 int r;
12 for (;;) {
13 if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; }
14 r = read(fd,sa->s + sa->len,bufsize);
15 if (r == -1) if (errno == error_intr) continue;
16 if (r <= 0) { close(fd); return r; }
17 sa->len += r;
18 }
19}