xref: /original-bsd/usr.bin/f77/libI77/endfile.c (revision bbb96de4)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)endfile.c	5.2	07/30/85
7  */
8 
9 /*
10  * endfile
11  */
12 
13 #include "fio.h"
14 
15 static char	endf[]	= "endfile";
16 
17 f_end (a)
18 alist	*a;
19 {
20 	unit	*b;
21 	int n;
22 
23 	lfname = NULL;
24 	elist = NO;
25 	errflag = a->aerr;
26 	lunit = a->aunit;
27 	if (not_legal(lunit))
28 		err (errflag, F_ERUNIT, endf)
29 	b = &units[lunit];
30 	if(!b->ufd && (n = fk_open(READ, SEQ, FMT, (ftnint)lunit)) )
31 		err(errflag, n, endf);
32 	if (b->uend)
33 		return(0);
34 	lfname = b->ufnm;
35 	b->uend = YES;
36 	return ( t_runc (b, errflag, endf) );
37 }
38