webber@athos.rutgers.edu (Bob Webber) (01/06/89)
*** xx Thu Jan 5 23:59:49 1989 --- INSERT.c Fri Jan 6 00:01:14 1989 *************** *** 5,10 **** --- 5,12 ---- #include <sys/file.h> #include <sys/param.h> + extern long lseek(); + main(argc,argv) int argc; char *argv[]; *************** *** 11,24 **** { int fdin, fdout; int ReadExit; - int WriteExit; - int SeekExit; int ReadSize; char chs[MAXBSIZE]; if (argc != 3) { ! fprintf(stderr,"Error 1 [%d]: Read the source before using\n",argc); exit(1); } if ((fdin = open(argv[1],O_RDONLY)) == -1) { --- 13,24 ---- { int fdin, fdout; int ReadExit; int ReadSize; char chs[MAXBSIZE]; if (argc != 3) { ! (void)fprintf(stderr,"Error 1 [%d]: Read the source before using\n",argc); exit(1); } if ((fdin = open(argv[1],O_RDONLY)) == -1) { *************** *** 25,31 **** perror("Error 2 : Read the source before using:"); exit(2); } ! if ((SeekExit = lseek(fdin,0,L_SET)) != 0) { perror("Error 3 : Read the source before using:"); exit(3); } --- 25,31 ---- perror("Error 2 : Read the source before using:"); exit(2); } ! if (lseek(fdin,(long) 0,L_SET) != 0) { perror("Error 3 : Read the source before using:"); exit(3); } *************** *** 33,39 **** perror("Error 4 : Read the source before using:"); exit(4); } ! if ((SeekExit = lseek(fdout,0,L_SET)) != 0) { perror("Error 5 : Read the source before using:"); exit(5); } --- 33,39 ---- perror("Error 4 : Read the source before using:"); exit(4); } ! if (lseek(fdout,(long) 0,L_SET) != 0) { perror("Error 5 : Read the source before using:"); exit(5); } *************** *** 40,46 **** ReadSize = 0; while ((ReadExit = read(fdin,chs,MAXBSIZE)) >0) { ReadSize += ReadExit; ! if ((WriteExit = write(fdout,chs,ReadExit)) != ReadExit) { perror("Error 6 : Read the source before using:"); exit(6); } --- 40,46 ---- ReadSize = 0; while ((ReadExit = read(fdin,chs,MAXBSIZE)) >0) { ReadSize += ReadExit; ! if (write(fdout,chs,ReadExit) != ReadExit) { perror("Error 6 : Read the source before using:"); exit(6); } *************** *** 56,59 **** } exit(0); } - --- 56,58 ----