2016-05-16 13:03:59 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
// non standard realization - no support for virtually change char
|
|
|
|
int ungetc(int c,FILE* file)
|
|
|
|
{
|
|
|
|
dword res;
|
|
|
|
|
2016-05-19 14:15:22 +02:00
|
|
|
if(!file)
|
|
|
|
{
|
|
|
|
errno = E_INVALIDPTR;
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((file->mode & 3!=FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0))
|
|
|
|
{
|
|
|
|
errno = E_ACCESS;
|
|
|
|
return EOF;
|
|
|
|
}
|
2016-05-16 13:03:59 +02:00
|
|
|
|
|
|
|
if (file->filepos>file->filesize || file->filepos==0)
|
|
|
|
{
|
2016-05-19 14:15:22 +02:00
|
|
|
errno = E_EOF;
|
2016-05-16 13:03:59 +02:00
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
file->filepos--;
|
|
|
|
|
|
|
|
return c;
|
2016-05-19 14:15:22 +02:00
|
|
|
}
|