kolibrios-fun/programs/develop/metcc/trunk/libc/file/fputc.c
Andrey Halyavin (halyavin) 51d395d0cc initial import of metcc project
git-svn-id: svn://kolibrios.org@145 a494cfbc-eb01-0410-851d-a64ba20cac60
2006-09-07 14:14:53 +00:00

25 lines
555 B
C

#include "stdio.h"
int fputc(int c,FILE* file)
{
void* p;
if ((file->mode & 3)==FILE_OPEN_READ)
return EOF;
if ((file->mode & 3)==FILE_OPEN_APPEND)
file->filepos=file->filesize;
if (file->filepos==file->filesize)
{
file->filesize++;
if (file->filesize>file->buffersize)
{
p=realloc(file->buffer,file->filesize+file->filesize<<1);
if (p==0)
return EOF;
file->buffersize=file->filesize+file->filesize<<1;
file->buffer=p;
}
}
file->buffer[file->filepos]=(char)c;
file->filepos++;
return 0;
}