Beispiel #1
0
size_t fread(void * buf, size_t size, size_t count, FILE * f)
{
	unsigned char * p = buf;
	size_t i;

	for(i = 0; i < count; i++)
	{
		if(__stdio_read(f, p, size) != size)
			break;

		p += size;
	}

	return i;
}
Beispiel #2
0
char * fgets(char * s, int n, FILE * f)
{
	char * p = s;
	char * ret = NULL;
	ssize_t res = 0;

	while(n-- > 1)
	{
		res = __stdio_read(f, (unsigned char *)p, 1);

		if(res == 0)
			break;

		else if(res < 0)
			return NULL;

		ret = s;
		if(*p++ == '\n')
			break;
	}

	*p = 0;
	return ret;
}
Beispiel #3
0
int fgetc(FILE * f)
{
	unsigned char res;

	return ((__stdio_read(f, &res, 1) <= 0) ? EOF : res);
}