Subversion Repositories Kolibri OS

Rev

Rev 6433 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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