#include /* * FMCPCMT copies COUNT characters from stream FIN to * the array of streams FLIST, where NUMOUT is the number of * elements of FLIST, returning the number of bytes copied or -1 on errors. * cc -c -O fmcpcmt.c * Written by Joe Pallas and Robert L. Kirby on September 25, 1980. */ int fmcpcmt(fin, flist, count, numout) int count, numout; /* unsigned(?) integers */ FILE *fin, *flist[]; { register int n; register unsigned int numread; register int total; char buf[BUFSIZ]; for(total = 0; numread = count - total; total += numread) { if (numread > BUFSIZ) numread = BUFSIZ; if ((numread = fread(buf, 1, numread, fin)) == 0) break; if (ferror(fin)) return(-1); for (n = 0; n < numout; n++) if (fwrite(buf, 1, numread, flist[n]) != numread) return(-1); } return(ferror(fin) ? -1 : total); }