Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libf2c / libI77 / rewind.c
1 #include "f2c.h"
2 #include "fio.h"
3 #ifdef KR_headers
4 integer f_rew(a) alist *a;
5 #else
6 integer f_rew(alist *a)
7 #endif
8 {
9         unit *b;
10         if (f__init & 2)
11                 f__fatal (131, "I/O recursion");
12         if(a->aunit>=MXUNIT || a->aunit<0)
13                 err(a->aerr,101,"rewind");
14         b = &f__units[a->aunit];
15         if(b->ufd == NULL || b->uwrt == 3)
16                 return(0);
17         if(!b->useek)
18                 err(a->aerr,106,"rewind");
19         if(b->uwrt) {
20                 (void) t_runc(a);
21                 b->uwrt = 3;
22                 }
23         rewind(b->ufd);
24         b->uend=0;
25         return(0);
26 }