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.

102 lines
3.0 KiB

  1. /***
  2. *fprintf.c - print formatted data to stream
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fprintf() - print formatted data to stream
  8. *
  9. *Revision History:
  10. * 09-02-83 RN initial version
  11. * 04-13-87 JCR added const to declaration
  12. * 06-24-87 JCR (1) Made declaration conform to ANSI prototype and use
  13. * the va_ macros; (2) removed SS_NE_DS conditionals.
  14. * 11-05-87 JCR Multi-thread support
  15. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  16. * 05-27-88 PHG Merged DLL and normal versions
  17. * 06-14-88 JCR Use near pointer to reference _iob[] entries
  18. * 08-25-88 GJF Don't use FP_OFF() macro for the 386
  19. * 08-17-89 GJF Clean up, now specific to OS/2 2.0 (i.e., 386 flat
  20. * model). Also fixed copyright and indents.
  21. * 02-15-90 GJF Fixed copyright
  22. * 03-19-90 GJF Made calling type _CALLTYPE2, added #include
  23. * <cruntime.h> and removed #include <register.h>.
  24. * 07-23-90 SBM Replaced <assertm.h> by <assert.h>
  25. * 10-02-90 GJF New-style function declarator.
  26. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  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. * 02-27-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 fprintf(stream, format, ...) - print formatted data
  42. *
  43. *Purpose:
  44. * Prints formatted data on the given using the format string to
  45. * format data and getting as many arguments as called for
  46. * _output does the real work here
  47. *
  48. *Entry:
  49. * FILE *stream - stream to print on
  50. * char *format - format string to control data format/number of arguments
  51. * followed by arguments to print, number and type controlled by
  52. * format string
  53. *
  54. *Exit:
  55. * returns number of characters printed
  56. *
  57. *Exceptions:
  58. *
  59. *******************************************************************************/
  60. int __cdecl fprintf (
  61. FILE *str,
  62. const char *format,
  63. ...
  64. )
  65. /*
  66. * 'F'ile (stream) 'PRINT', 'F'ormatted
  67. */
  68. {
  69. va_list(arglist);
  70. REG1 FILE *stream;
  71. REG2 int buffing;
  72. int retval;
  73. va_start(arglist, format);
  74. _ASSERTE(str != NULL);
  75. _ASSERTE(format != NULL);
  76. /* Init stream pointer */
  77. stream = str;
  78. #ifdef _MT
  79. _lock_str(stream);
  80. __try {
  81. #endif
  82. buffing = _stbuf(stream);
  83. retval = _output(stream,format,arglist);
  84. _ftbuf(buffing, stream);
  85. #ifdef _MT
  86. }
  87. __finally {
  88. _unlock_str(stream);
  89. }
  90. #endif
  91. return(retval);
  92. }