home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SRC / DUMPOUT.CP_ / DUMPOUT.CP
Encoding:
Text File  |  1993-02-08  |  2.5 KB  |  109 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library. 
  2. // Copyright (C) 1992 Microsoft Corporation 
  3. // All rights reserved. 
  4. //  
  5. // This source code is only intended as a supplement to the 
  6. // Microsoft Foundation Classes Reference and Microsoft 
  7. // QuickHelp and/or WinHelp documentation provided with the library. 
  8. // See these sources for detailed information regarding the 
  9. // Microsoft Foundation Classes product. 
  10.  
  11. #include "stdafx.h"
  12. #include <stdarg.h>
  13.  
  14. #ifdef AFX_AUX_SEG
  15. #pragma code_seg(AFX_AUX_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG   // entire file
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // Diagnostic Stream Globals
  22.  
  23. #ifndef _AFXDLL
  24. extern "C" BOOL NEAR afxTraceEnabled = 0;
  25.  
  26. #ifdef _WINDOWS
  27. extern "C" int NEAR afxTraceFlags = 0;
  28. #endif
  29. #endif //!_AFXDLL
  30.  
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Helper routines that can be called from debugger
  34.  
  35. extern "C" void AFXAPI AfxDump(const CObject* pOb)
  36. {
  37.     afxDump << pOb;
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Diagnostic Trace
  42.  
  43. extern "C" void CDECL 
  44. AfxTrace(LPCSTR pszFormat, ...)
  45. {
  46. #ifdef _DEBUG // all AfxTrace output is controlled by afxTraceEnabled
  47.     if (!afxTraceEnabled)
  48.         return;
  49. #endif //_DEBUG
  50.  
  51.     int nBuf;
  52. #ifndef _WINDLL
  53.     char szBuffer[512];
  54. #else
  55.     static char szBuffer[512];
  56. #endif
  57.     const char* pszLocalFormat;
  58.  
  59. #ifdef _NEARDATA
  60.     char szFormat[128];
  61.     ASSERT(lstrlen(pszFormat) < 128);
  62.     lstrcpy(szFormat, pszFormat);
  63.     pszLocalFormat = szFormat;
  64. #else
  65.     pszLocalFormat = pszFormat;
  66. #endif
  67.  
  68.     va_list args;
  69.     va_start(args, pszFormat);
  70.  
  71.     nBuf = vsprintf(szBuffer, pszLocalFormat, args);
  72.     ASSERT(nBuf < sizeof(szBuffer));
  73.  
  74. #ifdef _WINDOWS
  75.     if ((afxTraceFlags & 1) && (AfxGetApp() != NULL))
  76.         afxDump << AfxGetApp()->m_pszExeName << ": ";
  77. #endif
  78.  
  79.     afxDump << szBuffer;
  80. }
  81.  
  82. #ifdef _AFXDLL
  83.  
  84. #ifdef _NEARDATA
  85. #error _AFXDLL requires large model
  86. #endif
  87. #ifndef _WINDOWS
  88. #error _AFXDLL requires _WINDOWS
  89. #endif
  90.  
  91. extern "C"
  92. void AFX_EXPORT CALLBACK AfxTraceV(LPCSTR lpszFormat, const void FAR* lpArgs)
  93. {
  94.     int nBuf;
  95.     char szBuffer[512];
  96.  
  97.     nBuf = vsprintf(szBuffer, lpszFormat, (va_list)lpArgs);
  98.     ASSERT(nBuf < sizeof(szBuffer));
  99.  
  100.     if ((afxTraceFlags & 1) && (AfxGetApp() != NULL))
  101.         afxDump << AfxGetApp()->m_pszExeName << ": ";
  102.     afxDump << szBuffer;
  103. }
  104. #endif //_AFXDLL
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107.  
  108. #endif //_DEBUG, entire file
  109.