Subversion Repositories Kolibri OS

Rev

Rev 6432 | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. // non standard realization - no support for virtually change char
  3. int ungetc(int c,FILE* file)
  4. {
  5.         dword res;
  6.  
  7.     if(!file)
  8.     {
  9.         errno = E_INVALIDPTR;
  10.         return EOF;
  11.     }
  12.  
  13.         if ((file->mode & 3!=FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0))
  14.     {
  15.         errno = E_ACCESS;
  16.         return EOF;
  17.     }
  18.  
  19.         if (file->filepos>file->filesize || file->filepos==0)
  20.         {
  21.             errno = E_EOF;
  22.                 return EOF;
  23.         }
  24.         file->filepos--;
  25.  
  26.         return c;
  27. }
  28.