Rev 6433 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6432 | siemargl | 1 | #include |
7184 | siemargl | 2 | // non standard realization - support for virtually change ONLY ONE char |
3 | |||
4 | |||
5 | |||
6432 | siemargl | 6 | int ungetc(int c,FILE* file) |
7 | { |
||
8 | dword res; |
||
9 | |||
6433 | siemargl | 10 | if(!file) |
11 | { |
||
12 | errno = E_INVALIDPTR; |
||
13 | return EOF; |
||
14 | } |
||
6432 | siemargl | 15 | |
7184 | siemargl | 16 | if ((file->mode & 3) != FILE_OPEN_READ && (file->mode & FILE_OPEN_PLUS) == 0) |
6433 | siemargl | 17 | { |
18 | errno = E_ACCESS; |
||
19 | return EOF; |
||
20 | } |
||
21 | |||
7184 | siemargl | 22 | if (file->filepos > file->filesize || file->filepos == 0 || c == EOF || file->ungetc_buf != EOF) |
6432 | siemargl | 23 | { |
6433 | siemargl | 24 | errno = E_EOF; |
6432 | siemargl | 25 | return EOF; |
26 | } |
||
7184 | siemargl | 27 | |
28 | file->ungetc_buf = c; |
||
6432 | siemargl | 29 | file->filepos--; |
30 | |||
31 | return c; |
||
6433 | siemargl | 32 | } |