Source code of Windows XP (NT5)
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.

95 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. Author:
  7. Environment:
  8. Notes:
  9. Revision History:
  10. --*/
  11. #include <stdio.h> // vsprintf()
  12. #include <stdlib.h>
  13. #include <stdarg.h>
  14. #include <windows.h>
  15. #define DBGHDR "[cddump] "
  16. #define DBGHDRLEN (strlen( DBGHDR ))
  17. #if DBG
  18. //
  19. // Debug level global variable
  20. //
  21. // 0 = Extreme errors only
  22. // 1 = errors, major events
  23. // 2 = Standard debug level
  24. // 3 = Major code branches
  25. // 4+ = Step through code
  26. LONG DebugLevel = 0;
  27. VOID
  28. __cdecl
  29. CddumpDebugPrint(
  30. LONG DebugPrintLevel,
  31. PCHAR DebugMessage,
  32. ...
  33. )
  34. /*++
  35. Routine Description:
  36. Debug print for RedBook driver
  37. Arguments:
  38. Debug print level between 0 and x, with x being the most verbose.
  39. Return Value:
  40. None
  41. --*/
  42. {
  43. va_list ap;
  44. //
  45. // allow negative numbers
  46. //
  47. if ((DebugPrintLevel < 0) || (DebugPrintLevel <= DebugLevel)) {
  48. char buffer[200]; // Potential overflow
  49. //
  50. // single print so won't swap, obscuring message
  51. //
  52. va_start( ap, DebugMessage );
  53. RtlCopyMemory( buffer, DBGHDR, DBGHDRLEN );
  54. vsprintf(buffer+DBGHDRLEN, DebugMessage, ap);
  55. fprintf(stderr, buffer);
  56. va_end(ap);
  57. }
  58. }
  59. #else
  60. // nothing
  61. #endif // DBG