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