1*40865Sbostic /*- 2*40865Sbostic * Copyright (c) 1979 The Regents of the University of California. 3*40865Sbostic * All rights reserved. 4*40865Sbostic * 5*40865Sbostic * %sccs.include.redist.c% 6*40865Sbostic */ 71695Smckusick 8*40865Sbostic #ifndef lint 9*40865Sbostic static char sccsid[] = "@(#)RESET.c 1.9 (Berkeley) 04/09/90"; 10*40865Sbostic #endif /* not lint */ 111695Smckusick 121695Smckusick #include "h00vars.h" 131695Smckusick 141695Smckusick RESET(filep, name, maxnamlen, datasize) 151695Smckusick 161695Smckusick register struct iorec *filep; 171695Smckusick char *name; 183026Smckusic long maxnamlen; 193026Smckusic long datasize; 201695Smckusick { 211695Smckusick if (name == NULL && filep == INPUT && filep->fname[0] == '\0') { 2226243Slepreau if (fseek(filep->fbuf, (long)0, 0) == -1) { 233869Smckusic PERROR("Could not reset ", filep->pfname); 241695Smckusick return; 251695Smckusick } 267495Smckusick filep->funit &= ~EOFF; 277495Smckusick filep->funit |= (SYNC | EOLN); 281695Smckusick return; 291695Smckusick } 301695Smckusick filep = GETNAME(filep, name, maxnamlen, datasize); 311695Smckusick filep->fbuf = fopen(filep->fname, "r"); 321695Smckusick if (filep->fbuf == NULL) { 335717Smckusic /* 345717Smckusic * This allows unnamed temp files to be opened even if 355717Smckusic * they have not been rewritten yet. We decided to remove 365717Smckusic * this feature since the standard requires that files be 375717Smckusic * defined before being reset. 385717Smckusic * 391695Smckusick if (filep->funit & TEMP) { 401695Smckusick filep->funit |= (EOFF | SYNC | FREAD); 411695Smckusick return; 421695Smckusick } 435717Smckusic */ 443869Smckusic PERROR("Could not open ", filep->pfname); 451695Smckusick return; 461695Smckusick } 471695Smckusick filep->funit |= (SYNC | FREAD); 485024Smckusic if (filep->funit & FTEXT) 495024Smckusic filep->funit |= EOLN; 501695Smckusick if (filep->fblk > PREDEF) { 511695Smckusick setbuf(filep->fbuf, &filep->buf[0]); 521695Smckusick } 531695Smckusick } 54