| author | "Tomas Zeman <tomas.zeman@sun.com>" |
| Fri, 19 Oct 2007 14:06:22 +0200 | |
| changeset 0 | 068428edee47 |
| permissions | -rw-r--r-- |
| 0 | 1 |
#include "stralloc.h" |
2 |
#include "readwrite.h" |
|
3 |
#include "slurpclose.h" |
|
4 |
#include "error.h" |
|
5 |
||
6 |
int slurpclose(fd,sa,bufsize) |
|
7 |
int fd; |
|
8 |
stralloc *sa; |
|
9 |
int 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 |
} |