Commit | Line | Data |
---|---|---|
1f92ea9c TL |
1 | #include <stdio.h> |
2 | ||
3 | FILE * | |
4 | freopen(file, mode, iop) | |
5 | char *file; | |
6 | register char *mode; | |
7 | register FILE *iop; | |
8 | { | |
9 | register f; | |
10 | ||
11 | fclose(iop); | |
12 | if (*mode=='w') | |
13 | f = creat(file, 0666); | |
14 | else if (*mode=='a') { | |
15 | if ((f = open(file, 1)) < 0) | |
16 | f = creat(file, 0666); | |
17 | lseek(f, 0L, 2); | |
18 | } else | |
19 | f = open(file, 0); | |
20 | if (f < 0) | |
21 | return(NULL); | |
22 | iop->_file = f; | |
23 | if (*mode != 'r') | |
24 | iop->_flag |= _IOWRT; | |
25 | else | |
26 | iop->_flag |= _IOREAD; | |
27 | return(iop); | |
28 | } |