Subversion Repositories Kolibri OS

Rev

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

  1. #include "kolibc.h"
  2. #include "kolibri.h"
  3.  
  4. int write_buffer(FILE *f);
  5. int fill_buff(FILE* f);
  6.  
  7. int fputc(int c,FILE* f)
  8. {
  9.     if(!((f->mode & FILE_OPEN_WRITE)|(f->mode & FILE_OPEN_PLUS)))
  10.                 return EOF;
  11.  
  12.     if(!f->remain)
  13.     { if (!write_buffer(f))
  14.         return EOF;
  15.       f->filepos+=8192;        
  16.       fill_buff(f);
  17.     };  
  18.        
  19.     *f->stream = (char)c;
  20.     f->stream++;
  21.     f->remain--;
  22.     f->strpos++;
  23.     if((f->filepos+f->strpos) > f->filesize)
  24.       f->filesize=f->filepos+f->strpos;
  25.  
  26.         return c;
  27. };
  28.  
  29. int write_buffer(FILE *f)
  30. { size_t bytes;
  31.   int err;
  32.  
  33.   bytes= f->filepos+8192 > f->filesize ? f->strpos:8192;  
  34.   err=write_file(f->filename,f->buffer,f->filepos,bytes,&bytes);
  35.   if(err)
  36.     return 0;
  37.   return 1;  
  38. };
  39.