11679Smckusick /* Copyright (c) 1979 Regents of the University of California */ 21679Smckusick 3*3869Smckusic static char sccsid[] = "@(#)READ4.c 1.5 06/10/81"; 41679Smckusick 51679Smckusick #include "h00vars.h" 61679Smckusick 73019Smckusic long 81679Smckusick READ4(curfile) 91679Smckusick 101679Smckusick register struct iorec *curfile; 111679Smckusick { 123019Smckusic long data; 133019Smckusic int retval; 141679Smckusick 151679Smckusick if (curfile->funit & FWRITE) { 16*3869Smckusic ERROR("%s: Attempt to read, but open for writing\n", 17*3869Smckusic curfile->pfname); 181679Smckusick return; 191679Smckusick } 201679Smckusick UNSYNC(curfile); 212223Smckusic retval = fscanf(curfile->fbuf, "%ld", &data); 222223Smckusic if (retval == EOF) { 23*3869Smckusic ERROR("%s: Tried to read past end of file\n", curfile->pfname); 242223Smckusic return; 252223Smckusic } 262223Smckusic if (retval == 0) { 27*3869Smckusic ERROR("%s: Bad data found on integer read\n", curfile->pfname); 281679Smckusick return; 291679Smckusick } 302309Smckusic curfile->funit &= ~EOLN; 311679Smckusick curfile->funit |= SYNC; 321679Smckusick return data; 331679Smckusick } 34