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.

86 lines
1.9 KiB

  1. /***
  2. *fputws.c - write a string to a stream
  3. *
  4. * Copyright (c) 1993-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fputws() - writes a string to a stream
  8. *
  9. *Revision History:
  10. * 04-26-93 CFW Module created.
  11. * 02-07-94 CFW POSIXify.
  12. * 09-06-94 CFW Replace MTHREAD with _MT.
  13. * 02-06-94 CFW assert -> _ASSERTE.
  14. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  15. * 02-27-98 GJF Exception-safe locking.
  16. * 01-04-99 GJF Changes for 64-bit size_t.
  17. *
  18. *******************************************************************************/
  19. #ifndef _POSIX_
  20. #include <file2.h>
  21. #include <internal.h>
  22. #include <stdio.h>
  23. #include <mtdll.h>
  24. #include <tchar.h>
  25. #include <wchar.h>
  26. #include <dbgint.h>
  27. /***
  28. *int fputws(string, stream) - write a string to a file
  29. *
  30. *Purpose:
  31. * Output the given string to the stream, don't write the L'\0' or
  32. * supply a L'\n'. Uses _stbuf and _ftbuf for efficiency reasons.
  33. *
  34. *Entry:
  35. * wchar_t *string - string to write
  36. * FILE *stream - stream to write to.
  37. *
  38. *Exit:
  39. * Good return = 0
  40. * Error return = WEOF
  41. *
  42. *Exceptions:
  43. *
  44. *******************************************************************************/
  45. int __cdecl fputws (
  46. const wchar_t *string,
  47. FILE *stream
  48. )
  49. {
  50. size_t length;
  51. int retval = 0;
  52. _ASSERTE(string != NULL);
  53. _ASSERTE(stream != NULL);
  54. length = wcslen(string);
  55. #ifdef _MT
  56. _lock_str(stream);
  57. __try {
  58. #endif
  59. while (length--)
  60. {
  61. if (_putwc_lk(*string++, stream) == WEOF)
  62. {
  63. retval = -1;
  64. break;
  65. }
  66. }
  67. #ifdef _MT
  68. }
  69. __finally {
  70. _unlock_str(stream);
  71. }
  72. #endif
  73. return(retval);
  74. }
  75. #endif /* _POSIX_ */