# #define BUFSIZ 512 /* * MCPCMT copies COUNT characters from file descriptor FDIN to * the array of file descriptors FDLIST, where NUMOUT is the number of * elements of FDLIST, returning the number of bytes copied or -1 on errors. * cc -c -O mcpcmt.c * Written by Joe Pallas and Robert L. Kirby on September 25, 1980. */ int mcpcmt(fdin, fdlist, count, numout) int count, numout; /* unsigned(?) integers */ int fdin, fdlist[]; { 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 = read(fdin, buf, numread)) == 0) break; if (numread == -1) return(-1); for (n = 0; n < numout; n++) if (write(fdlist[n], buf, numread) != numread) return(-1); } return(total); }