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.

98 lines
2.9 KiB

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