Initial revision
[mmh] / sbr / cpydata.c
1
2 /*
3  * cpydata.c -- copy all data from one fd to another
4  *
5  * $Id$
6  */
7
8 #include <h/mh.h>
9
10 void
11 cpydata (int in, int out, char *ifile, char *ofile)
12 {
13     int i;
14     char buffer[BUFSIZ];
15
16     while ((i = read(in, buffer, sizeof(buffer))) > 0) {
17         if (write(out, buffer, i) != i)
18             adios(ofile, "error writing");
19     }
20
21     if (i == -1)
22         adios(ifile, "error reading");
23 }