Subversion Repositories Kolibri OS

Rev

Rev 6433 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
647 andrew_pro 1
#include 
2
int fgetc(FILE* file)
3
{
4
	dword res;
6433 siemargl 5
    if(!file)
6
    {
7
        errno = E_INVALIDPTR;
8
        return EOF;
9
    }
647 andrew_pro 10
 
7172 siemargl 11
	if ((file->mode & 3)!=FILE_OPEN_READ && (file->mode & FILE_OPEN_PLUS)==0) return EOF;
647 andrew_pro 12
 
13
	if (file->filepos>=file->filesize)
14
	{
15
		return EOF;
16
	}
17
	else
18
	{
19
		res=_ksys_readfile(file->filename,file->filepos,1,file->buffer);
20
		if (res==0)
21
		{
22
			file->filepos++;
23
  			return (int)file->buffer[0];
24
		}
6433 siemargl 25
		else
26
        {
27
            errno = -res;
28
            return EOF;  // errors are < 0
29
        }
647 andrew_pro 30
	}
6433 siemargl 31
}