xref: /original-bsd/usr.bin/pascal/libpc/REWRITE.c (revision 6c57d260)
1 /* Copyright (c) 1979 Regents of the University of California */
2 
3 static char sccsid[] = "@(#)REWRITE.c 1.2 03/07/81";
4 
5 #include "h00vars.h"
6 #include "h01errs.h"
7 
8 REWRITE(filep, name, maxnamlen, datasize)
9 
10 	register struct iorec	*filep;
11 	char			*name;
12 	long			maxnamlen;
13 	long			datasize;
14 {
15 	filep = GETNAME (filep, name, maxnamlen, datasize);
16 	filep->fbuf = fopen(filep->fname, "w");
17 	if (filep->fbuf == NULL) {
18 		ERROR(ECREATE, filep->pfname);
19 		return;
20 	}
21 	filep->funit |= (EOFF | FWRITE);
22 	if (filep->fblk > PREDEF) {
23 		setbuf(filep->fbuf, &filep->buf[0]);
24 	}
25 }
26