home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / FLUSH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  585 b   |  26 lines

  1. /* flush.c (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <stdio.h>
  5. #include <io.h>
  6. #include <fcntl.h>
  7. #include <errno.h>
  8.  
  9. int _flush (int c, FILE *stream)
  10. {
  11.   if (!(stream->flags & _IOOPEN) || stream->flush == NULL)
  12.     {
  13.       errno = EACCES;
  14.       return (EOF);
  15.     }
  16.   if (stream->flags & _IOREAD)    /* File in read mode? */
  17.     {
  18.       stream->flags |= _IOERR;
  19.       errno = EACCES;
  20.       return (EOF);
  21.     }
  22.   if (stream->flush (stream, (unsigned char)c) != 0)
  23.     return (EOF);
  24.   return ((unsigned char)c);
  25. }
  26.