xref: /original-bsd/lib/libc/stdio/rewind.c (revision 39b8935c)
1 /*
2  * Copyright (c) 1987 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)rewind.c	5.5 (Berkeley) 06/01/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/types.h>
13 #include <sys/file.h>
14 #include <stdio.h>
15 
16 rewind(iop)
17 	register FILE *iop;
18 {
19 	off_t lseek();
20 
21 	(void)fflush(iop);
22 	(void)lseek(fileno(iop), 0L, L_SET);
23 	iop->_cnt = 0;
24 	iop->_ptr = iop->_base;
25 	iop->_flag &= ~(_IOERR|_IOEOF);
26 	if (iop->_flag & _IORW)
27 		iop->_flag &= ~(_IOREAD|_IOWRT);
28 }
29