xref: /csrg-svn/usr.bin/pascal/libpc/RESET.c (revision 3869)
11695Smckusick /* Copyright (c) 1979 Regents of the University of California */
21695Smckusick 
3*3869Smckusic static char sccsid[] = "@(#)RESET.c 1.4 06/10/81";
41695Smckusick 
51695Smckusick #include "h00vars.h"
61695Smckusick 
71695Smckusick RESET(filep, name, maxnamlen, datasize)
81695Smckusick 
91695Smckusick 	register struct iorec	*filep;
101695Smckusick 	char			*name;
113026Smckusic 	long			maxnamlen;
123026Smckusic 	long			datasize;
131695Smckusick {
141695Smckusick 	if (name == NULL && filep == INPUT && filep->fname[0] == '\0') {
153663Smckusic 		if (fseek(filep->fbuf, (long)0, 0)) {
16*3869Smckusic 			PERROR("Could not reset ", filep->pfname);
171695Smckusick 			return;
181695Smckusick 		}
191695Smckusick 		filep->funit &= ~(EOFF | EOLN);
201695Smckusick 		filep->funit |= SYNC;
211695Smckusick 		return;
221695Smckusick 	}
231695Smckusick 	filep = GETNAME(filep, name, maxnamlen, datasize);
241695Smckusick 	filep->fbuf = fopen(filep->fname, "r");
251695Smckusick 	if (filep->fbuf == NULL) {
261695Smckusick 		if (filep->funit & TEMP) {
271695Smckusick 			filep->funit |= (EOFF | SYNC | FREAD);
281695Smckusick 			return;
291695Smckusick 		}
30*3869Smckusic 		PERROR("Could not open ", filep->pfname);
311695Smckusick 		return;
321695Smckusick 	}
331695Smckusick 	filep->funit |= (SYNC | FREAD);
341695Smckusick 	if (filep->fblk > PREDEF) {
351695Smckusick 		setbuf(filep->fbuf, &filep->buf[0]);
361695Smckusick 	}
371695Smckusick }
38