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
|
|
|
|
|
|
|
ptr[i] = c;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|