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.

90 lines
2.2 KiB

  1. /***
  2. *wprintf.c - print formatted
  3. *
  4. * Copyright (c) 1992-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wprintf() - print formatted data
  8. *
  9. *Revision History:
  10. * 05-16-92 KRS Created from printf.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-95 CFW assert -> _ASSERTE.
  15. * 03-07-95 GJF Use _[un]lock_str2 instead of _[un]lock_str. Also,
  16. * removed useless local and macros.
  17. * 03-02-98 GJF Exception-safe locking.
  18. *
  19. *******************************************************************************/
  20. #ifndef _POSIX_
  21. #include <cruntime.h>
  22. #include <stdio.h>
  23. #include <dbgint.h>
  24. #include <stdarg.h>
  25. #include <file2.h>
  26. #include <internal.h>
  27. #include <mtdll.h>
  28. /***
  29. *int wprintf(format, ...) - print formatted data
  30. *
  31. *Purpose:
  32. * Prints formatted data on stdout using the format string to
  33. * format data and getting as many arguments as called for
  34. * Uses temporary buffering to improve efficiency.
  35. * _output does the real work here
  36. *
  37. *Entry:
  38. * wchar_t *format - format string to control data format/number of arguments
  39. * followed by list of arguments, number and type controlled by
  40. * format string
  41. *
  42. *Exit:
  43. * returns number of wide characters printed
  44. *
  45. *Exceptions:
  46. *
  47. *******************************************************************************/
  48. int __cdecl wprintf (
  49. const wchar_t *format,
  50. ...
  51. )
  52. /*
  53. * stdout 'W'char_t 'PRINT', 'F'ormatted
  54. */
  55. {
  56. va_list arglist;
  57. int buffing;
  58. int retval;
  59. // UNDONE: make va_start work with wchar_t format string
  60. va_start(arglist, format);
  61. _ASSERTE(format != NULL);
  62. #ifdef _MT
  63. _lock_str2(1, stdout);
  64. __try {
  65. #endif
  66. buffing = _stbuf(stdout);
  67. retval = _woutput(stdout,format,arglist);
  68. _ftbuf(buffing, stdout);
  69. #ifdef _MT
  70. }
  71. __finally {
  72. _unlock_str2(1, stdout);
  73. }
  74. #endif
  75. return(retval);
  76. }
  77. #endif /* _POSIX_ */