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

  1. /***
  2. *wrt2err.c - write an LSTRING to stderr (Win32 version)
  3. *
  4. *       Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       This module contains a routine __wrt2err that writes an LSTRING
  8. *       (one byte length followed by the several bytes of the string)
  9. *       to the standard error handle (2).  This is a helper routine used
  10. *       for MATH error messages (and also FORTRAN error messages).
  11. *
  12. *******************************************************************************/
  13.  
  14.  
  15. #include <cruntime.h>
  16. #include <oscalls.h>
  17. #include <internal.h>
  18.  
  19. /***
  20. *__wrt2err(msg) - write an LSTRING to stderr
  21. *
  22. *Purpose:
  23. *       Takes a pointer to an LSTRING which is to be written to standard error.
  24. *       An LSTRING is a one-byte length followed by that many bytes for the
  25. *       character string (as opposed to a null-terminated string).
  26. *
  27. *Entry:
  28. *       char *msg = pointer to LSTRING to write to standard error.
  29. *
  30. *Exit:
  31. *       Nothing returned.
  32. *
  33. *Exceptions:
  34. *       None handled.
  35. *
  36. *******************************************************************************/
  37.  
  38. void __cdecl __wrt2err (
  39.         char *msg
  40.         )
  41. {
  42.         unsigned long length;           /* length of string to write */
  43.         unsigned long numwritten;       /* number of bytes written */
  44.  
  45.         length = *msg++;                /* 1st byte is length */
  46.  
  47.         /* write the message to stderr */
  48.  
  49.         WriteFile((HANDLE)_osfhnd(2), msg, length, &numwritten, NULL);
  50. }
  51.  
  52.