Source code of Windows XP (NT5)
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.6 KiB

  1. /***
  2. *vprintf.c - printf from a var args pointer
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines vprintf() - print formatted data from an argument list pointer
  8. *
  9. *Revision History:
  10. * 09-02-83 RN original printf
  11. * 06-17-85 TC rewrote to use new varargs macros to be vprintf
  12. * 04-13-87 JCR added const to declaration
  13. * 11-06-87 JCR Multi-thread support
  14. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  15. * 05-31-88 PHG Merged DLL and normal versions
  16. * 06-15-88 JCR Near reference to _iob[] entries; improve REG variables
  17. * 08-18-89 GJF Clean up, now specific to OS/2 2.0 (i.e., 386 flat
  18. * model). Also fixed copyright and indents.
  19. * 02-16-90 GJF Fixed copyright
  20. * 03-20-90 GJF Made calling type _CALLTYPE1, added #include
  21. * <cruntime.h> and removed #include <register.h>.
  22. * 07-25-90 SBM Replaced <assertm.h> by <assert.h>, <varargs.h> by
  23. * <stdarg.h>
  24. * 10-03-90 GJF New-style function declarator.
  25. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  26. * 09-06-94 CFW Replace MTHREAD with _MT.
  27. * 02-06-94 CFW assert -> _ASSERTE.
  28. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  29. * 03-02-98 GJF Exception-safe locking.
  30. *
  31. *******************************************************************************/
  32. #include <cruntime.h>
  33. #include <stdio.h>
  34. #include <dbgint.h>
  35. #include <stdarg.h>
  36. #include <internal.h>
  37. #include <file2.h>
  38. #include <mtdll.h>
  39. /***
  40. *int vprintf(format, ap) - print formatted data from an argument list pointer
  41. *
  42. *Purpose:
  43. * Prints formatted data items to stdout. Uses a pointer to a
  44. * variable length list of arguments instead of an argument list.
  45. *
  46. *Entry:
  47. * char *format - format string, describes data format to write
  48. * va_list ap - pointer to variable length arg list
  49. *
  50. *Exit:
  51. * returns number of characters written
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. int __cdecl vprintf (
  57. const char *format,
  58. va_list ap
  59. )
  60. /*
  61. * stdout 'V'ariable, 'PRINT', 'F'ormatted
  62. */
  63. {
  64. REG1 FILE *stream = stdout;
  65. REG2 int buffing;
  66. REG3 int retval;
  67. _ASSERTE(format != NULL);
  68. #ifdef _MT
  69. _lock_str(stream);
  70. __try {
  71. #endif
  72. buffing = _stbuf(stream);
  73. retval = _output(stream, format, ap );
  74. _ftbuf(buffing, stream);
  75. #ifdef _MT
  76. }
  77. __finally {
  78. _unlock_str(stream);
  79. }
  80. #endif
  81. return(retval);
  82. }