140865Sbostic /*- 2*62094Sbostic * Copyright (c) 1979, 1993 3*62094Sbostic * The Regents of the University of California. All rights reserved. 440865Sbostic * 540865Sbostic * %sccs.include.redist.c% 640865Sbostic */ 71679Smckusick 840865Sbostic #ifndef lint 9*62094Sbostic static char sccsid[] = "@(#)READ4.c 8.1 (Berkeley) 06/06/93"; 1040865Sbostic #endif /* not lint */ 111679Smckusick 121679Smckusick #include "h00vars.h" 136498Smckusick #include <errno.h> 146498Smckusick extern int errno; 151679Smckusick 163019Smckusic long READ4(curfile)171679SmckusickREAD4(curfile) 181679Smckusick 191679Smckusick register struct iorec *curfile; 201679Smckusick { 213019Smckusic long data; 223019Smckusic int retval; 231679Smckusick 241679Smckusick if (curfile->funit & FWRITE) { 253869Smckusic ERROR("%s: Attempt to read, but open for writing\n", 263869Smckusic curfile->pfname); 271679Smckusick } 281679Smckusick UNSYNC(curfile); 296498Smckusick errno = 0; 302223Smckusic retval = fscanf(curfile->fbuf, "%ld", &data); 312223Smckusic if (retval == EOF) { 323869Smckusic ERROR("%s: Tried to read past end of file\n", curfile->pfname); 332223Smckusic } 342223Smckusic if (retval == 0) { 353869Smckusic ERROR("%s: Bad data found on integer read\n", curfile->pfname); 361679Smckusick } 376498Smckusick if (errno == ERANGE) { 386498Smckusick ERROR("%s: Overflow on integer read\n", curfile->pfname); 396498Smckusick } 406498Smckusick if (errno != 0) { 4115128Smckusick PERROR("Error encountered on integer read ", curfile->pfname); 426498Smckusick } 431679Smckusick return data; 441679Smckusick } 45