Commit | Line | Data |
---|---|---|
a58c9769 KM |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | ||
86997b19 | 3 | static char sccsid[] = "@(#)RESET.c 1.4 %G%"; |
a58c9769 KM |
4 | |
5 | #include "h00vars.h" | |
a58c9769 KM |
6 | |
7 | RESET(filep, name, maxnamlen, datasize) | |
8 | ||
9 | register struct iorec *filep; | |
10 | char *name; | |
492cc5d3 KM |
11 | long maxnamlen; |
12 | long datasize; | |
a58c9769 KM |
13 | { |
14 | if (name == NULL && filep == INPUT && filep->fname[0] == '\0') { | |
10b672b5 | 15 | if (fseek(filep->fbuf, (long)0, 0)) { |
86997b19 | 16 | PERROR("Could not reset ", filep->pfname); |
a58c9769 KM |
17 | return; |
18 | } | |
19 | filep->funit &= ~(EOFF | EOLN); | |
20 | filep->funit |= SYNC; | |
21 | return; | |
22 | } | |
23 | filep = GETNAME(filep, name, maxnamlen, datasize); | |
24 | filep->fbuf = fopen(filep->fname, "r"); | |
25 | if (filep->fbuf == NULL) { | |
26 | if (filep->funit & TEMP) { | |
27 | filep->funit |= (EOFF | SYNC | FREAD); | |
28 | return; | |
29 | } | |
86997b19 | 30 | PERROR("Could not open ", filep->pfname); |
a58c9769 KM |
31 | return; |
32 | } | |
33 | filep->funit |= (SYNC | FREAD); | |
34 | if (filep->fblk > PREDEF) { | |
35 | setbuf(filep->fbuf, &filep->buf[0]); | |
36 | } | |
37 | } |