Subversion Repositories Kolibri OS

Rev

Rev 7172 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7172 Rev 7184
Line 1... Line 1...
1
#include 
1
#include 
2
int fgetc(FILE* file)
2
int fgetc(FILE* file)
3
{
3
{
4
	dword res;
-
 
5
    if(!file)
-
 
6
    {
-
 
7
        errno = E_INVALIDPTR;
-
 
8
        return EOF;
4
	int c = 0, rc;
9
    }
-
 
Line 10... Line 5...
10
 
5
	
Line 11... Line 6...
11
	if ((file->mode & 3)!=FILE_OPEN_READ && (file->mode & FILE_OPEN_PLUS)==0) return EOF;
6
	rc = fread(&c, 1, 1, file);
12
 
7
 
13
	if (file->filepos>=file->filesize)
8
	if (rc < 1) return EOF;
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
		}
-
 
25
		else
-
 
26
        {
-
 
27
            errno = -res;
-
 
28
            return EOF;  // errors are < 0
-
 
29
        }
9