1/* See LICENSE file for copyright and license details. */
2#include <stdio.h>
3
4#include "../text.h"
5#include "../util.h"
6
7void
8fconcat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
9{
10 char buf[BUFSIZ];
11 size_t n;
12
13 while ((n = fread(buf, 1, sizeof(buf), fp1)) > 0) {
14 if (fwrite(buf, 1, n, fp2) != n)
15 eprintf("%s: write error:", s2);
16 if (feof(fp1))
17 break;
18 }
19 if (ferror(fp1))
20 eprintf("%s: read error:", s1);
21}