2021-03-02 18:58:11 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream) {
|
|
|
|
unsigned bytes_read = 0;
|
|
|
|
unsigned bytes_count = size * nmemb;
|
2021-03-02 19:57:57 +01:00
|
|
|
|
|
|
|
for (size_t i = 0; i < bytes_count; i++) {
|
|
|
|
char c = fgetc(stream);
|
|
|
|
|
|
|
|
if (c == EOF) {
|
|
|
|
break;
|
2021-03-02 18:58:11 +01:00
|
|
|
}
|
2021-03-02 19:57:57 +01:00
|
|
|
|
2021-03-02 21:49:28 +01:00
|
|
|
*(char*)(ptr+i) = c;
|
2021-03-02 19:57:57 +01:00
|
|
|
|
|
|
|
bytes_read++;
|
2021-03-02 18:58:11 +01:00
|
|
|
}
|
2021-03-02 19:57:57 +01:00
|
|
|
|
2021-03-02 18:58:11 +01:00
|
|
|
return bytes_read / size;
|
|
|
|
}
|