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.

159 lines
3.5 KiB

  1. /* Copyright (c) 1991-1994 Microsoft Corporation */
  2. /*
  3. debug.c
  4. Support code for the dprintf routines.
  5. Note that all of this is conditional on the DBG flag
  6. */
  7. #define NOGDICAPMASKS
  8. #define NOVIRTUALKEYCODES
  9. #define NOWINSTYLES
  10. #define NOSYSMETRICS
  11. #define NOMENUS
  12. #define NOICONS
  13. #define NOKEYSTATES
  14. #define NOSYSCOMMANDS
  15. #define NORASTEROPS
  16. #define NOSHOWWINDOW
  17. #define OEMRESOURCE
  18. #define NOATOM
  19. #define NOCLIPBOARD
  20. #define NOCOLOR
  21. #define NOCTLMGR
  22. #define NODRAWTEXT
  23. #define NOGDI
  24. #define NOKERNEL
  25. #define NONLS
  26. #define NOMB
  27. #define NOMEMMGR
  28. #define NOMETAFILE
  29. #define NOMINMAX
  30. #define NOOPENFILE
  31. #define NOSCROLL
  32. #define NOTEXTMETRIC
  33. #define NOWH
  34. #define NOWINOFFSETS
  35. #define NOCOMM
  36. #define NOKANJI
  37. #define NOHELP
  38. #define NOPROFILER
  39. #define NODEFERWINDOWPOS
  40. #define NOMMDRV
  41. #define MMNOMMIO
  42. #define MMNOJOY
  43. #define MMNOTIMER
  44. #define MMNOAUX
  45. #define MMNOMIDI
  46. #define MMNOWAVE
  47. #include <windows.h>
  48. #include "mciwave.h" // private include file
  49. #include <stdarg.h>
  50. #if DBG
  51. #ifdef MEDIA_DEBUG
  52. int mciwaveDebugLevel = 1;
  53. #else
  54. int mciwaveDebugLevel = 1;
  55. #endif
  56. /***************************************************************************
  57. @doc INTERNAL
  58. @api void | mciwaveDbgOut | This function sends output to the current
  59. debug output device.
  60. @parm LPSTR | lpszFormat | Pointer to a printf style format string.
  61. @parm ??? | ... | Args.
  62. @rdesc There is no return value.
  63. ****************************************************************************/
  64. void mciwaveDbgOut(LPSTR lpszFormat, ...)
  65. {
  66. char buf[256];
  67. UINT n;
  68. va_list va;
  69. UINT offset;
  70. // If the last character is a comma, do not add the newline
  71. // If the first character is a period, do not add thread/module info
  72. n = wsprintf(buf, "MCIWAVE: (tid %x) ", GetCurrentThreadId());
  73. offset = n;
  74. va_start(va, lpszFormat);
  75. n += vsprintf(buf+n, lpszFormat, va);
  76. if (*(buf+offset) == '.') {
  77. offset++;
  78. } else {
  79. offset = 0;
  80. }
  81. va_end(va);
  82. if (',' != buf[n-1]) {
  83. buf[n++] = '\n';
  84. }
  85. buf[n] = 0;
  86. OutputDebugString(buf+offset);
  87. Sleep(10); // let terminal catch up
  88. }
  89. void mciwaveInitDebugLevel(void)
  90. {
  91. UINT level = GetProfileInt("MMDEBUG", "MCIWAVE", 99);
  92. if (level != 99) {
  93. mciwaveDebugLevel = level;
  94. }
  95. }
  96. /***************************************************************************
  97. @doc INTERNAL
  98. @api void | dDbgAssert | This function prints an assertion message.
  99. @parm LPSTR | exp | Pointer to the expression string.
  100. @parm LPSTR | file | Pointer to the file name.
  101. @parm int | line | The line number.
  102. @rdesc There is no return value.
  103. ****************************************************************************/
  104. void dDbgAssert(LPSTR exp, LPSTR file, int line)
  105. {
  106. dprintf1(("Assertion failure:"));
  107. dprintf1((" Exp: %s", exp));
  108. dprintf1((" File: %s, line: %d", file, line));
  109. DebugBreak();
  110. }
  111. #endif // DBG
  112. /**************************************************************************
  113. @doc INTERNAL
  114. @api void | mciwaveSetDebugLevel | Set the current debug level
  115. @parm int | iLevel | The new level to set
  116. @rdesc There is no return value
  117. **************************************************************************/
  118. void mciwaveSetDebugLevel(int level)
  119. {
  120. #if DBG
  121. mciwaveDebugLevel = level;
  122. dprintf(("debug level set to %d", mciwaveDebugLevel));
  123. #endif
  124. }