1 /* Copyright (c) 1979 Regents of the University of California */ 2 3 static char sccsid[] = "@(#)READ4.c 1.5 06/10/81"; 4 5 #include "h00vars.h" 6 7 long 8 READ4(curfile) 9 10 register struct iorec *curfile; 11 { 12 long data; 13 int retval; 14 15 if (curfile->funit & FWRITE) { 16 ERROR("%s: Attempt to read, but open for writing\n", 17 curfile->pfname); 18 return; 19 } 20 UNSYNC(curfile); 21 retval = fscanf(curfile->fbuf, "%ld", &data); 22 if (retval == EOF) { 23 ERROR("%s: Tried to read past end of file\n", curfile->pfname); 24 return; 25 } 26 if (retval == 0) { 27 ERROR("%s: Bad data found on integer read\n", curfile->pfname); 28 return; 29 } 30 curfile->funit &= ~EOLN; 31 curfile->funit |= SYNC; 32 return data; 33 } 34