1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)fread.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include    <stdio.h>
  12: 
  13: fread(ptr, size, count, iop)
  14:     register char *ptr;
  15:     unsigned size, count;
  16:     register FILE *iop;
  17: {
  18:     register unsigned s;
  19:     int c;
  20: 
  21:     s = size * count;
  22:     while (s > 0) {
  23:         if (iop->_cnt < s) {
  24:             if (iop->_cnt > 0) {
  25:                 bcopy(iop->_ptr, ptr, iop->_cnt);
  26:                 ptr += iop->_cnt;
  27:                 s -= iop->_cnt;
  28:             }
  29:             /*
  30: 			 * filbuf clobbers _cnt & _ptr,
  31: 			 * so don't waste time setting them.
  32: 			 */
  33:             if ((c = _filbuf(iop)) == EOF)
  34:                 break;
  35:             *ptr++ = c;
  36:             s--;
  37:         }
  38:         if (iop->_cnt >= s) {
  39:             bcopy(iop->_ptr, ptr, s);
  40:             iop->_ptr += s;
  41:             iop->_cnt -= s;
  42:             return (count);
  43:         }
  44:     }
  45:     return (size != 0 ? count - ((s + size - 1) / size) : 0);
  46: }

Defined functions

fread defined in line 13; used 286 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1987-03-15
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3045
Valid CSS Valid XHTML 1.0 Strict