xref: /original-bsd/usr.bin/f77/libI77/rewind.c (revision f3455753)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)rewind.c	5.3 (Berkeley) 04/12/91";
10 #endif /* not lint */
11 
12 /*
13  * rewind.c  -  f77 file rewind
14  */
15 
16 #include "fio.h"
17 
18 static char	rwnd[]	= "rewind";
19 
f_rew(a)20 f_rew(a) alist *a;
21 {	int n;
22 	unit *b;
23 
24 	lfname = NULL;
25 	elist = NO;
26 	external = YES;			/* for err */
27 	lunit = a->aunit;
28 	errflag = a->aerr;
29 	if(not_legal(lunit)) err(errflag,F_ERUNIT,rwnd)
30 	b = &units[lunit];
31 	if(!b->ufd) return(OK);
32 	lfname = b->ufnm;
33 	if(!b->useek) err(errflag,F_ERNOBKSP,rwnd)
34 	b->uend = NO;
35 	if(b->uwrt)
36 		if(n=t_runc(b,errflag,rwnd)) return(n);
37 	rewind(b->ufd);
38 	return(OK);
39 }
40