xref: /csrg-svn/lib/libc/stdio/rewind.c (revision 42633)
132735Sbostic /*
232735Sbostic  * Copyright (c) 1987 Regents of the University of California.
332735Sbostic  * All rights reserved.
432735Sbostic  *
5*42633Sbostic  * %sccs.include.redist.c%
632735Sbostic  */
732735Sbostic 
826659Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42633Sbostic static char sccsid[] = "@(#)rewind.c	5.5 (Berkeley) 06/01/90";
1032735Sbostic #endif /* LIBC_SCCS and not lint */
1122144Smckusick 
1232735Sbostic #include <sys/types.h>
1332735Sbostic #include <sys/file.h>
1432735Sbostic #include <stdio.h>
152030Swnj 
162030Swnj rewind(iop)
1732735Sbostic 	register FILE *iop;
182030Swnj {
1932735Sbostic 	off_t lseek();
2032735Sbostic 
2132735Sbostic 	(void)fflush(iop);
2232735Sbostic 	(void)lseek(fileno(iop), 0L, L_SET);
232030Swnj 	iop->_cnt = 0;
242030Swnj 	iop->_ptr = iop->_base;
252030Swnj 	iop->_flag &= ~(_IOERR|_IOEOF);
263163Stoy 	if (iop->_flag & _IORW)
273163Stoy 		iop->_flag &= ~(_IOREAD|_IOWRT);
282030Swnj }
29