xref: /csrg-svn/usr.bin/pascal/libpc/FNIL.c (revision 1652)
1*1652Smckusick /* Copyright (c) 1979 Regents of the University of California */
2*1652Smckusick 
3*1652Smckusick static char sccsid[] = "@(#)FNIL.c 1.1 10/30/80";
4*1652Smckusick 
5*1652Smckusick #include "h00vars.h"
6*1652Smckusick #include "h01errs.h"
7*1652Smckusick 
8*1652Smckusick char *
9*1652Smckusick FNIL(curfile)
10*1652Smckusick 
11*1652Smckusick 	register struct iorec	*curfile;
12*1652Smckusick {
13*1652Smckusick 	if (curfile->fblk >= MAXFILES || _actfile[curfile->fblk] != curfile) {
14*1652Smckusick 		ERROR(ENOFILE, 0);
15*1652Smckusick 		return;
16*1652Smckusick 	}
17*1652Smckusick 	if (curfile->funit & FDEF) {
18*1652Smckusick 		ERROR(EREFINAF, curfile->pfname);
19*1652Smckusick 		return;
20*1652Smckusick 	}
21*1652Smckusick 	if (curfile->funit & FREAD) {
22*1652Smckusick 		IOSYNC(curfile);
23*1652Smckusick 		if (curfile->funit & EOFF) {
24*1652Smckusick 			ERROR(EPASTEOF, curfile->pfname);
25*1652Smckusick 			return;
26*1652Smckusick 		}
27*1652Smckusick 	}
28*1652Smckusick 	return curfile->fileptr;
29*1652Smckusick }
30