home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / FLUSHALL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  56 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - flushall.c
  3.  *
  4.  * function(s)
  5.  *        flushall - clears all buffers
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <RtlData.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name            flushall - clears all buffers
  23.  
  24. Usage           int flushall(void);
  25.  
  26. Prototype in    stdio.h
  27.  
  28. Description     clears all buffers associated with open input streams,
  29.                 and writes all buffers associated with open output streams
  30.                 to their respective files.  Any read operation following
  31.                 flushall reads new data into the buffers from the input
  32.                 files.
  33.  
  34. Return value    the number of open input and output streams
  35.  
  36. *---------------------------------------------------------------------*/
  37. int _FARFUNC flushall(void)
  38. {
  39.     register FILE   *fp;
  40.     register int    Nb;
  41.     int     Cpt;
  42.     _QRTLDataBlock;
  43.  
  44.     for (Cpt = 0, Nb = _QRTLInstanceData(_nfile), fp = _QRTLInstanceData(_streams);
  45.          Nb--;
  46.          fp++)
  47.  
  48.     if (fp->flags & _F_RDWR)
  49.         {
  50.         fflush(fp);
  51.         Cpt++;
  52.         }
  53.  
  54.     return(Cpt);
  55. }
  56.