1 /*- 2 * Copyright (c) 1979 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)RESET.c 1.9 (Berkeley) 04/09/90"; 10 #endif /* not lint */ 11 12 #include "h00vars.h" 13 14 RESET(filep, name, maxnamlen, datasize) 15 16 register struct iorec *filep; 17 char *name; 18 long maxnamlen; 19 long datasize; 20 { 21 if (name == NULL && filep == INPUT && filep->fname[0] == '\0') { 22 if (fseek(filep->fbuf, (long)0, 0) == -1) { 23 PERROR("Could not reset ", filep->pfname); 24 return; 25 } 26 filep->funit &= ~EOFF; 27 filep->funit |= (SYNC | EOLN); 28 return; 29 } 30 filep = GETNAME(filep, name, maxnamlen, datasize); 31 filep->fbuf = fopen(filep->fname, "r"); 32 if (filep->fbuf == NULL) { 33 /* 34 * This allows unnamed temp files to be opened even if 35 * they have not been rewritten yet. We decided to remove 36 * this feature since the standard requires that files be 37 * defined before being reset. 38 * 39 if (filep->funit & TEMP) { 40 filep->funit |= (EOFF | SYNC | FREAD); 41 return; 42 } 43 */ 44 PERROR("Could not open ", filep->pfname); 45 return; 46 } 47 filep->funit |= (SYNC | FREAD); 48 if (filep->funit & FTEXT) 49 filep->funit |= EOLN; 50 if (filep->fblk > PREDEF) { 51 setbuf(filep->fbuf, &filep->buf[0]); 52 } 53 } 54