Subversion Repositories Kolibri OS

Rev

Rev 8730 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <errno.h>
  3. // non standard realization - support for virtually change ONLY ONE char
  4.  
  5. int ungetc(int c, FILE* file)
  6. {
  7.         int res;
  8.  
  9.     if(!file){
  10.         errno = EBADF;
  11.         return EOF;
  12.     }
  13.  
  14.         if (file->mode != _FILEMODE_R){
  15.         errno = EACCES;
  16.         return EOF;
  17.     }
  18.  
  19.         if (file->position == 0 || c == EOF)
  20.         {
  21.             errno = EOF;
  22.                 return EOF;
  23.         }
  24.        
  25.         file->__ungetc_emu_buff = c;
  26.         file->position--;
  27.         return c;
  28. }
  29.