diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
| commit | 69aec538b456402170dc723af417ba5c05389c32 (patch) | |
| tree | e6f34c543f17c6392447ea337b2e2868212424d1 /slurpclose.c | |
| download | qmail-69aec538b456402170dc723af417ba5c05389c32.tar.gz qmail-69aec538b456402170dc723af417ba5c05389c32.tar.bz2 qmail-69aec538b456402170dc723af417ba5c05389c32.zip | |
qmail 1.03 import
Diffstat (limited to 'slurpclose.c')
| -rw-r--r-- | slurpclose.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/slurpclose.c b/slurpclose.c new file mode 100644 index 0000000..2fcef15 --- /dev/null +++ b/slurpclose.c | |||
| @@ -0,0 +1,19 @@ | |||
| 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 | } | ||
