Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.4 KiB

  1. /***
  2. *clearerr.c - clear error and eof flags
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines clearerr() - clear error and eof flags from a stream
  8. *
  9. *Revision History:
  10. * 11-30-83 RN initial version
  11. * 11-02-87 JCR Multi-thread support
  12. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  13. * 05-31-88 PHG Merged DLL and normal versions
  14. * 06-01-88 JCR Clear lowio flags as well as stdio flags
  15. * 02-15-90 GJF Fixed copyright and indents
  16. * 03-16-90 GJF Replaced _LOAD_DS with _CALLTYPE1 and added #include
  17. * <cruntime.h>.
  18. * 07-23-90 SBM Replaced <assertm.h> by <assert.h>
  19. * 10-02-90 GJF New-style function declarator.
  20. * 01-22-91 GJF ANSI naming.
  21. * 03-27-92 DJM POSIX support
  22. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  23. * 09-06-94 CFW Replace MTHREAD with _MT.
  24. * 02-06-94 CFW assert -> _ASSERTE.
  25. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  26. * 06-12-95 GJF Replaced _osfile[] with _osfile() (macro referencing
  27. * field in ioinfo struct).
  28. * 07-28-95 GJF Replaced _osfile() with _osfile_safe().
  29. * 02-25-98 GJF Exception-safe locking.
  30. * 05-17-99 PML Remove all Macintosh support.
  31. *
  32. *******************************************************************************/
  33. #include <cruntime.h>
  34. #include <stdio.h>
  35. #include <dbgint.h>
  36. #include <file2.h>
  37. #include <mtdll.h>
  38. #include <internal.h>
  39. #ifndef _POSIX_
  40. #include <msdos.h>
  41. #endif
  42. /***
  43. *void clearerr(stream) - clear error and eof flags on a stream
  44. *
  45. *Purpose:
  46. * Resets the error and eof indicators for a stream to 0
  47. *
  48. *Entry:
  49. * FILE *stream - stream to set indicators on
  50. *
  51. *Exit:
  52. * No return value.
  53. * changes the _flag field of the FILE struct.
  54. *
  55. *Exceptions:
  56. *
  57. *******************************************************************************/
  58. void __cdecl clearerr (
  59. FILE *stream
  60. )
  61. {
  62. _ASSERTE(stream != NULL);
  63. #ifdef _MT
  64. _lock_str(stream);
  65. __try {
  66. #endif
  67. /* Clear stdio level flags */
  68. stream->_flag &= ~(_IOERR|_IOEOF);
  69. /* Clear lowio level flags */
  70. #ifndef _POSIX_
  71. _osfile_safe(_fileno(stream)) &= ~(FEOFLAG);
  72. #endif
  73. #ifdef _MT
  74. }
  75. __finally {
  76. _unlock_str(stream);
  77. }
  78. #endif
  79. }