Leaked source code of windows server 2003
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.

106 lines
2.6 KiB

  1. /***
  2. *fgetc.c - get a character from a stream
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fgetc() and getc() - read a character from a stream
  8. *
  9. *Revision History:
  10. * 09-01-83 RN initial version
  11. * 11-09-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-21-89 PHG Added getc() function
  15. * 02-15-90 GJF Fixed copyright and indents
  16. * 03-16-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  17. * <cruntime.h> and removed #include <register.h>.
  18. * 03-16-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  19. * 07-24-90 SBM Replaced <assertm.h> by <assert.h>
  20. * 10-02-90 GJF New-style function declarators.
  21. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  22. * 04-26-93 CFW Wide char enable.
  23. * 04-30-93 CFW Remove wide char support to fgetwc.c.
  24. * 09-06-94 CFW Replace MTHREAD with _MT.
  25. * 02-06-94 CFW assert -> _ASSERTE.
  26. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  27. * 07-20-97 GJF Made getc() identical to fgetc(). Also, detab-ed.
  28. * 02-27-98 GJF Exception-safe locking.
  29. *
  30. *******************************************************************************/
  31. #include <cruntime.h>
  32. #include <stdio.h>
  33. #include <dbgint.h>
  34. #include <file2.h>
  35. #include <internal.h>
  36. #include <mtdll.h>
  37. /***
  38. *int fgetc(stream), getc(stream) - read a character from a stream
  39. *
  40. *Purpose:
  41. * reads a character from the given stream
  42. *
  43. *Entry:
  44. * FILE *stream - stream to read character from
  45. *
  46. *Exit:
  47. * returns the character read
  48. * returns EOF if at end of file or error occurred
  49. *
  50. *Exceptions:
  51. *
  52. *******************************************************************************/
  53. int __cdecl fgetc (
  54. REG1 FILE *stream
  55. )
  56. {
  57. int retval;
  58. _ASSERTE(stream != NULL);
  59. #ifdef _MT
  60. _lock_str(stream);
  61. __try {
  62. #endif
  63. retval = _getc_lk(stream);
  64. #ifdef _MT
  65. }
  66. __finally {
  67. _unlock_str(stream);
  68. }
  69. #endif
  70. return(retval);
  71. }
  72. #undef getc
  73. int __cdecl getc (
  74. FILE *stream
  75. )
  76. {
  77. int retval;
  78. _ASSERTE(stream != NULL);
  79. #ifdef _MT
  80. _lock_str(stream);
  81. __try {
  82. #endif
  83. retval = _getc_lk(stream);
  84. #ifdef _MT
  85. }
  86. __finally {
  87. _unlock_str(stream);
  88. }
  89. #endif
  90. return(retval);
  91. }