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.

114 lines
2.9 KiB

  1. /***
  2. *fputc.c - write a character to an output stream
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fputc() - writes a character to a stream
  8. * defines fputwc() - writes a wide character to a stream
  9. *
  10. *Revision History:
  11. * 09-01-83 RN initial version
  12. * 11-09-87 JCR Multi-thread support
  13. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  14. * 05-27-88 PHG Merged DLL and normal versions
  15. * 06-14-88 JCR Near reference to _iob[] entries; improve REG variables
  16. * 08-25-88 GJF Don't use FP_OFF() macro for the 386
  17. * 06-21-89 PHG Added putc() function
  18. * 08-28-89 JCR Removed _NEAR_ for 386
  19. * 02-15-90 GJF Fixed copyright and indents.
  20. * 03-19-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  21. * <cruntime.h> and removed #include <register.h>. Also,
  22. * removed some leftover 16-bit support.
  23. * 07-24-90 SBM Replaced <assertm.h> by <assert.h>
  24. * 10-02-90 GJF New-style function declarators.
  25. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  26. * 04-26-93 CFW Wide char enable.
  27. * 04-30-93 CFW Remove wide char support to fputwc.c.
  28. * 09-06-94 CFW Replace MTHREAD with _MT.
  29. * 02-06-94 CFW assert -> _ASSERTE.
  30. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  31. * 02-20-97 GJF Removed unnecessary local from fputc(). Made putc()
  32. * identical to fputc(). Also, detab-ed.
  33. * 02-27-98 GJF Exception-safe locking.
  34. *
  35. *******************************************************************************/
  36. #include <cruntime.h>
  37. #include <stdio.h>
  38. #include <dbgint.h>
  39. #include <file2.h>
  40. #include <internal.h>
  41. #include <mtdll.h>
  42. /***
  43. *int fputc(ch, stream) - write a character to a stream
  44. *
  45. *Purpose:
  46. * Writes a character to a stream. Function version of putc().
  47. *
  48. *Entry:
  49. * int ch - character to write
  50. * FILE *stream - stream to write to
  51. *
  52. *Exit:
  53. * returns the character if successful
  54. * returns EOF if fails
  55. *
  56. *Exceptions:
  57. *
  58. *******************************************************************************/
  59. int __cdecl fputc (
  60. int ch,
  61. FILE *str
  62. )
  63. {
  64. int retval;
  65. _ASSERTE(str != NULL);
  66. #ifdef _MT
  67. _lock_str(str);
  68. __try {
  69. #endif
  70. retval = _putc_lk(ch,str);
  71. #ifdef _MT
  72. }
  73. __finally {
  74. _unlock_str(str);
  75. }
  76. #endif
  77. return(retval);
  78. }
  79. #undef putc
  80. int __cdecl putc (
  81. int ch,
  82. FILE *str
  83. )
  84. {
  85. int retval;
  86. _ASSERTE(str != NULL);
  87. #ifdef _MT
  88. _lock_str(str);
  89. __try {
  90. #endif
  91. retval = _putc_lk(ch,str);
  92. #ifdef _MT
  93. }
  94. __finally {
  95. _unlock_str(str);
  96. }
  97. #endif
  98. return(retval);
  99. }