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.

70 lines
2.2 KiB

  1. //**************************************************************************
  2. //
  3. // DEBUG.C -- Xena Gaming Project
  4. //
  5. // Version 3.XX
  6. //
  7. // Copyright (c) 1997 Microsoft Corporation. All rights reserved.
  8. //
  9. // @doc
  10. // @module DEBUG.C | Supports debugging output (DBG builds only)
  11. //**************************************************************************
  12. #if (DBG==1) // skip rest of file
  13. //---------------------------------------------------------------------------
  14. // Include Files
  15. //---------------------------------------------------------------------------
  16. #include "msgame.h"
  17. #include <stdio.h>
  18. #include <stdarg.h>
  19. //---------------------------------------------------------------------------
  20. // Private Data
  21. //---------------------------------------------------------------------------
  22. DBG_LEVEL DebugLevel = DBG_DEFAULT;
  23. //---------------------------------------------------------------------------
  24. // @func Set conditional debug level
  25. // @parm DBG_LEVEL | uLevel | New debug output priority
  26. // @rdesc Old debug output priority
  27. // @comm Public function available on DBG builds only
  28. //---------------------------------------------------------------------------
  29. DBG_LEVEL DEBUG_Level (DBG_LEVEL uLevel)
  30. {
  31. EXCHANGE(uLevel, DebugLevel);
  32. return (uLevel);
  33. };
  34. //---------------------------------------------------------------------------
  35. // @func Writes conditional debug output
  36. // @parm DBG_LEVEL | uLevel | Debug output priority
  37. // @parm PCSZ | szMessage | Formating string
  38. // @parmvar One or more variable arguments
  39. // @rdesc None
  40. // @comm Public function available on DBG builds only
  41. //---------------------------------------------------------------------------
  42. VOID DEBUG_Print (DBG_LEVEL uLevel, PCSZ szMessage, ...)
  43. {
  44. va_list ap;
  45. va_start (ap, szMessage);
  46. if (uLevel <= DebugLevel)
  47. {
  48. CHAR szBuffer[256];
  49. _vsnprintf (szBuffer, sizeof (szBuffer), szMessage, ap);
  50. DbgPrint (szBuffer);
  51. }
  52. va_end (ap);
  53. }
  54. //===========================================================================
  55. // End
  56. //===========================================================================
  57. #endif // DBG=1