kolibrios/programs/develop/ktcc/trunk/libc/stdio/ungetc.c
siemargl ace23ebbe2 libc testsuite + fixes
git-svn-id: svn://kolibrios.org@6433 a494cfbc-eb01-0410-851d-a64ba20cac60
2016-05-19 12:15:22 +00:00

28 lines
495 B
C

#include <stdio.h>
// non standard realization - no support for virtually change char
int ungetc(int c,FILE* file)
{
dword res;
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;
}
if (file->filepos>file->filesize || file->filepos==0)
{
errno = E_EOF;
return EOF;
}
file->filepos--;
return c;
}