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[] = "@(#)fwrite.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include    <stdio.h>
  12: 
  13: fwrite(ptr, size, count, iop)
  14:     register char *ptr;
  15:     unsigned size, count;
  16:     register FILE *iop;
  17: {
  18:     register unsigned s;
  19: 
  20:     s = size * count;
  21:     if (iop->_flag & _IOLBF)
  22:         while (s > 0) {
  23:             if (--iop->_cnt > -iop->_bufsiz && *ptr != '\n')
  24:                 *iop->_ptr++ = *ptr++;
  25:             else if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF)
  26:                 break;
  27:             s--;
  28:         }
  29:     else while (s > 0) {
  30:         if (iop->_cnt < s) {
  31:             if (iop->_cnt > 0) {
  32:                 bcopy(ptr, iop->_ptr, iop->_cnt);
  33:                 ptr += iop->_cnt;
  34:                 iop->_ptr += iop->_cnt;
  35:                 s -= iop->_cnt;
  36:             }
  37:             if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF)
  38:                 break;
  39:             s--;
  40:         }
  41:         if (iop->_cnt >= s) {
  42:             bcopy(ptr, iop->_ptr, s);
  43:             iop->_ptr += s;
  44:             iop->_cnt -= s;
  45:             return (count);
  46:         }
  47:     }
  48:     return (size != 0 ? count - ((s + size - 1) / size) : 0);
  49: }

Defined functions

fwrite defined in line 13; used 244 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: 2453
Valid CSS Valid XHTML 1.0 Strict