1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * 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 5.1 (Berkeley) 01/20/91"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <errno.h> 16 #include <stdio.h> 17 #include "local.h" 18 19 /* 20 * fpurge: like fflush, but without writing anything: leave the 21 * given FILE's buffer empty. 22 */ 23 int 24 fpurge(fp) 25 register FILE *fp; 26 { 27 if (!fp->_flags) { 28 errno = EBADF; 29 return(EOF); 30 } 31 32 if (HASUB(fp)) 33 FREEUB(fp); 34 fp->_p = fp->_bf._base; 35 fp->_r = 0; 36 fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; 37 return (0); 38 } 39