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