Commit | Line | Data |
---|---|---|
2117e02e MW |
1 | #include "stralloc.h" |
2 | #include "readwrite.h" | |
3 | #include "slurpclose.h" | |
4 | ||
5 | int slurpclose(fd,sa,bufsize) | |
6 | int fd; | |
7 | stralloc *sa; | |
8 | int bufsize; | |
9 | { | |
10 | int r; | |
11 | for (;;) { | |
12 | if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; } | |
13 | r = read(fd,sa->s + sa->len,bufsize); | |
14 | if (r <= 0) { close(fd); return r; } | |
15 | sa->len += r; | |
16 | } | |
17 | } |