home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / clearerr.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  59 lines

  1. /***
  2. *clearerr.c - clear error and eof flags
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines clearerr() - clear error and eof flags from a stream
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <stdio.h>
  13. #include <dbgint.h>
  14. #include <file2.h>
  15. #include <mtdll.h>
  16. #include <internal.h>
  17. #include <msdos.h>
  18.  
  19. /***
  20. *void clearerr(stream) - clear error and eof flags on a stream
  21. *
  22. *Purpose:
  23. *       Resets the error and eof indicators for a stream to 0
  24. *
  25. *Entry:
  26. *       FILE *stream - stream to set indicators on
  27. *
  28. *Exit:
  29. *       No return value.
  30. *       changes the _flag field of the FILE struct.
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35.  
  36. void __cdecl clearerr (
  37.         FILE *stream
  38.         )
  39. {
  40.         _ASSERTE(stream != NULL);
  41.  
  42.         _lock_str(stream);
  43.  
  44.         /* Clear stdio level flags */
  45.         stream->_flag &= ~(_IOERR|_IOEOF);
  46.  
  47.         /* Clear lowio level flags */
  48.  
  49. #ifdef _WIN32
  50.  
  51.         _osfile_safe(_fileno(stream)) &= ~(FEOFLAG);
  52.  
  53. #else  /* _WIN32 */
  54.         _osfile[_fileno(stream)] &= ~(FEOFLAG);
  55. #endif  /* _WIN32 */
  56.  
  57.         _unlock_str(stream);
  58. }
  59.