home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / CLIBS / IO / FREAD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-08  |  478 b   |  24 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <libp.h>
  6.  
  7. int fread(unsigned char *buf, size_t size, size_t count, FILE *stream)
  8. {
  9.     int rv;
  10.     int len = count * size,i;
  11.     if (stream->token != FILTOK)
  12.         return 0;
  13.     if (!(stream->flags & _F_READ)) {
  14.         stream->flags |= _F_ERR;
  15.         return 0;
  16.     }
  17.     for (i=0; i < len; i++) {
  18.         rv = _basegetc(stream);
  19.         if (rv == EOF)
  20.             return i / size;
  21.         *buf++ = (char) rv;
  22.     }
  23.     return count;
  24. }