Commit | Line | Data |
---|---|---|
45ead4dd KB |
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 | ||
2ce81398 | 13 | #if defined(LIBC_SCCS) && !defined(lint) |
45ead4dd KB |
14 | static char sccsid[] = "@(#)rewind.c 5.3 (Berkeley) %G%"; |
15 | #endif /* LIBC_SCCS and not lint */ | |
b8f253e8 | 16 | |
45ead4dd KB |
17 | #include <sys/types.h> |
18 | #include <sys/file.h> | |
19 | #include <stdio.h> | |
8c222d3d BJ |
20 | |
21 | rewind(iop) | |
45ead4dd | 22 | register FILE *iop; |
8c222d3d | 23 | { |
45ead4dd KB |
24 | off_t lseek(); |
25 | ||
26 | (void)fflush(iop); | |
27 | (void)lseek(fileno(iop), 0L, L_SET); | |
8c222d3d BJ |
28 | iop->_cnt = 0; |
29 | iop->_ptr = iop->_base; | |
30 | iop->_flag &= ~(_IOERR|_IOEOF); | |
d8af6b8b MT |
31 | if (iop->_flag & _IORW) |
32 | iop->_flag &= ~(_IOREAD|_IOWRT); | |
8c222d3d | 33 | } |