]> diplodocus.org Git - nmh/blob - sbr/cpydata.c
Improve fmttest output
[nmh] / sbr / cpydata.c
1 /* cpydata.c -- copy all data from one fd to another
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include "h/mh.h"
9 #include "cpydata.h"
10 #include "error.h"
11
12 void
13 cpydata (int in, int out, const char *ifile, const char *ofile)
14 {
15 int i;
16 char buffer[BUFSIZ];
17
18 while ((i = read(in, buffer, sizeof(buffer))) > 0) {
19 if (write(out, buffer, i) != i)
20 adios(ofile, "error writing");
21 }
22
23 if (i == -1)
24 adios(ifile, "error reading");
25 }