51d395d0cc
git-svn-id: svn://kolibrios.org@145 a494cfbc-eb01-0410-851d-a64ba20cac60
25 lines
555 B
C
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;
|
|
}
|