xref: /original-bsd/lib/libc/stdio/rewind.c (revision d0e3910b)
1 /*
2  * Copyright (c) 1987 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific written prior permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #if defined(LIBC_SCCS) && !defined(lint)
14 static char sccsid[] = "@(#)rewind.c	5.3 (Berkeley) 12/02/87";
15 #endif /* LIBC_SCCS and not lint */
16 
17 #include <sys/types.h>
18 #include <sys/file.h>
19 #include <stdio.h>
20 
21 rewind(iop)
22 	register FILE *iop;
23 {
24 	off_t lseek();
25 
26 	(void)fflush(iop);
27 	(void)lseek(fileno(iop), 0L, L_SET);
28 	iop->_cnt = 0;
29 	iop->_ptr = iop->_base;
30 	iop->_flag &= ~(_IOERR|_IOEOF);
31 	if (iop->_flag & _IORW)
32 		iop->_flag &= ~(_IOREAD|_IOWRT);
33 }
34