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.

93 lines
2.3 KiB

  1. /***
  2. *fwprintf.c - print formatted data to stream
  3. *
  4. * Copyright (c) 1992-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fwprintf() - print formatted data to stream
  8. *
  9. *Revision History:
  10. * 05-16-92 KRS Created from fprintf.c.
  11. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  12. * 02-07-94 CFW POSIXify.
  13. * 09-06-94 CFW Replace MTHREAD with _MT.
  14. * 02-06-94 CFW assert -> _ASSERTE.
  15. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  16. * 03-02-98 GJF Exception-safe locking.
  17. *
  18. *******************************************************************************/
  19. #ifndef _POSIX_
  20. #include <cruntime.h>
  21. #include <stdio.h>
  22. #include <dbgint.h>
  23. #include <stdarg.h>
  24. #include <file2.h>
  25. #include <internal.h>
  26. #include <mtdll.h>
  27. /***
  28. *int fwprintf(stream, format, ...) - print formatted data
  29. *
  30. *Purpose:
  31. * Prints formatted data on the given using the format string to
  32. * format data and getting as many arguments as called for
  33. * _output does the real work here
  34. *
  35. *Entry:
  36. * FILE *stream - stream to print on
  37. * wchar_t *format - format string to control data format/number of arguments
  38. * followed by arguments to print, number and type controlled by
  39. * format string
  40. *
  41. *Exit:
  42. * returns number of wide characters printed
  43. *
  44. *Exceptions:
  45. *
  46. *******************************************************************************/
  47. int __cdecl fwprintf (
  48. FILE *str,
  49. const wchar_t *format,
  50. ...
  51. )
  52. /*
  53. * 'F'ile (stream) 'W'char_t 'PRINT', 'F'ormatted
  54. */
  55. {
  56. va_list(arglist);
  57. REG1 FILE *stream;
  58. REG2 int buffing;
  59. int retval;
  60. // UNDONE: make va_start work with wchar_t format string
  61. va_start(arglist, format);
  62. _ASSERTE(str != NULL);
  63. _ASSERTE(format != NULL);
  64. /* Init stream pointer */
  65. stream = str;
  66. #ifdef _MT
  67. _lock_str(stream);
  68. __try {
  69. #endif
  70. buffing = _stbuf(stream);
  71. retval = _woutput(stream,format,arglist);
  72. _ftbuf(buffing, stream);
  73. #ifdef _MT
  74. }
  75. __finally {
  76. _unlock_str(stream);
  77. }
  78. #endif
  79. return(retval);
  80. }
  81. #endif /* _POSIX_ */