home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / windebug.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-06  |  3.3 KB  |  150 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright 1992 - 1998 Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. //  debug.c
  13. //
  14. //  Description:
  15. //      This file contains code yanked from several places to provide debug
  16. //      support that works in win 16 and win 32.
  17. //
  18. //
  19. //==========================================================================;
  20.  
  21. #ifdef _DEBUG
  22. #include <windows.h>
  23. #include <windowsx.h>
  24. #include <mmsystem.h>
  25. #include <stdarg.h>
  26. #include "windebug.h"
  27.  
  28. BOOL    __gfDbgEnabled          = TRUE;         // master enable
  29. UINT    __guDbgLevel            = 0;            // current debug level
  30.  
  31.  
  32. //--------------------------------------------------------------------------;
  33. //
  34. //  void DbgVPrintF
  35. //
  36. //  Description:
  37. //
  38. //
  39. //  Arguments:
  40. //      LPSTR szFormat:
  41. //
  42. //      va_list va:
  43. //
  44. //  Return (void):
  45. //      No value is returned.
  46. //
  47. //--------------------------------------------------------------------------;
  48. #define DEBUG_MAX_LINE_LEN 2048
  49.  
  50. void FAR CDECL DbgVPrintF
  51. (
  52.     LPSTR                   szFormat,
  53.     va_list                 va
  54. )
  55. {
  56.     char                ach[DEBUG_MAX_LINE_LEN];
  57.     BOOL                fDebugBreak = FALSE;
  58.     BOOL                fPrefix     = TRUE;
  59.     BOOL                fCRLF       = TRUE;
  60.  
  61.     ach[0] = '\0';
  62.  
  63.     for (;;)
  64.     {
  65.         switch (*szFormat)
  66.         {
  67.             case '!':
  68.                 fDebugBreak = TRUE;
  69.                 szFormat++;
  70.                 continue;
  71.  
  72.             case '`':
  73.                 fPrefix = FALSE;
  74.                 szFormat++;
  75.                 continue;
  76.  
  77.             case '~':
  78.                 fCRLF = FALSE;
  79.                 szFormat++;
  80.                 continue;
  81.         }
  82.  
  83.         break;
  84.     }
  85.  
  86.     if (fDebugBreak)
  87.     {
  88.         ach[0] = '\007';
  89.         ach[1] = '\0';
  90.     }
  91.     wvsprintfA(ach + lstrlenA(ach), szFormat, va);
  92.  
  93.     if (fCRLF)
  94.     {
  95.         lstrcatA(ach, "\r\n");
  96.     }
  97.  
  98.     OutputDebugStringA(ach);
  99.  
  100.     if (fDebugBreak)
  101.     {
  102.         DebugBreak();
  103.     }
  104. } // DbgVPrintF()
  105.  
  106.  
  107. //--------------------------------------------------------------------------;
  108. //
  109. //  void dprintf
  110. //
  111. //  Description:
  112. //      dprintf() is called by the DPF() macro if DEBUG is defined at compile
  113. //      time. It is recommended that you only use the DPF() macro to call
  114. //      this function--so you don't have to put #ifdef DEBUG around all
  115. //      of your code.
  116. //
  117. //  Arguments:
  118. //      UINT uDbgLevel:
  119. //
  120. //      LPSTR szFormat:
  121. //
  122. //  Return (void):
  123. //      No value is returned.
  124. //
  125. //--------------------------------------------------------------------------;
  126.  
  127. void FAR CDECL dprintf
  128. (
  129. //    UINT                    uDbgLevel,
  130.     LPSTR                   szFormat,
  131.     ...
  132. )
  133. {
  134.     va_list va;
  135.  
  136.  //   if (!__gfDbgEnabled || (__guDbgLevel < uDbgLevel))
  137.   //      return;
  138.  
  139.     va_start(va, szFormat);
  140.     DbgVPrintF(szFormat, va);
  141.     va_end(va);
  142. } // dprintf()
  143.  
  144.  
  145.  
  146. #endif // #ifdef DEBUG
  147.  
  148.  
  149.  
  150.