Subversion Repositories Kolibri OS

Rev

Rev 8624 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <stdio.h>
  2.  
  3. size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream) {
  4.         unsigned bytes_read = 0;
  5.         unsigned bytes_count = size * nmemb;
  6.  
  7.         for (size_t i = 0; i < bytes_count; i++) {
  8.                 char c = fgetc(stream);
  9.  
  10.                 if (c == EOF) {
  11.                         break;
  12.                 }
  13.  
  14.                 *(char*)(ptr+i) = c;
  15.  
  16.                 bytes_read++;
  17.         }
  18.  
  19.         return bytes_read / size;
  20. }
  21.