home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / vfprintf.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  67 lines

  1. /***
  2. *vfprintf.c - fprintf from variable arg list
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines vfprintf() - print formatted output, but take args from
  8. *       a stdargs pointer.
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <stdio.h>
  14. #include <dbgint.h>
  15. #include <stdarg.h>
  16. #include <file2.h>
  17. #include <internal.h>
  18. #include <mtdll.h>
  19.  
  20. /***
  21. *int vfprintf(stream, format, ap) - print to file from varargs
  22. *
  23. *Purpose:
  24. *       Performs formatted output to a file.  The arg list is a variable
  25. *       argument list pointer.
  26. *
  27. *Entry:
  28. *       FILE *stream - stream to write data to
  29. *       char *format - format string containing data format
  30. *       va_list ap - variable arg list pointer
  31. *
  32. *Exit:
  33. *       returns number of correctly output characters
  34. *       returns negative number if error occurred
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39.  
  40. int __cdecl vfprintf (
  41.         FILE *str,
  42.         const char *format,
  43.         va_list ap
  44.         )
  45. /*
  46.  * 'V'ariable argument 'F'ile (stream) 'PRINT', 'F'ormatted
  47.  */
  48. {
  49.         REG1 FILE *stream;
  50.         REG2 int buffing;
  51.         REG3 int retval;
  52.  
  53.         _ASSERTE(str != NULL);
  54.         _ASSERTE(format != NULL);
  55.  
  56.         /* Init stream pointer */
  57.         stream = str;
  58.  
  59.         _lock_str(stream);
  60.         buffing = _stbuf(stream);
  61.         retval = _output(stream,format,ap );
  62.         _ftbuf(buffing, stream);
  63.         _unlock_str(stream);
  64.  
  65.         return(retval);
  66. }
  67.