1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #if defined(LIBC_SCCS) && !defined(lint) 12 static char sccsid[] = "@(#)fpurge.c 8.1 (Berkeley) 06/04/93"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <errno.h> 16 #include <stdio.h> 17 #include <stdlib.h> 18 #include "local.h" 19 20 /* 21 * fpurge: like fflush, but without writing anything: leave the 22 * given FILE's buffer empty. 23 */ 24 int 25 fpurge(fp) 26 register FILE *fp; 27 { 28 if (!fp->_flags) { 29 errno = EBADF; 30 return(EOF); 31 } 32 33 if (HASUB(fp)) 34 FREEUB(fp); 35 fp->_p = fp->_bf._base; 36 fp->_r = 0; 37 fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; 38 return (0); 39 } 40