blob: 2e9aa521efb427e520b517aa51554e6533bda865 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* See LICENSE file for copyright and license details. */
#include <unistd.h>
#include "../util.h"
int
concat(int f1, const char *s1, int f2, const char *s2)
{
char buf[BUFSIZ];
ssize_t n;
while ((n = read(f1, buf, sizeof(buf))) > 0) {
if (writeall(f2, buf, n) < 0) {
weprintf("write %s:", s2);
return -2;
}
}
if (n < 0) {
weprintf("read %s:", s1);
return -1;
}
return 0;
}
|