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.

119 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996-2003 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. local.h
  6. // @@BEGIN_DDKSPLIT
  7. Abstract:
  8. Environment:
  9. User Mode -Win32
  10. Revision History:
  11. // @@END_DDKSPLIT
  12. --*/
  13. #ifndef _LOCAL_H_
  14. #define _LOCAL_H_
  15. LPWSTR AllocSplStr(LPCWSTR pStr);
  16. LPVOID AllocSplMem(DWORD cbAlloc);
  17. #define FreeSplMem( pMem ) ((pMem) ? (GlobalFree(pMem) ? FALSE:TRUE):TRUE)
  18. #define FreeSplStr( lpStr ) ((lpStr) ? (GlobalFree(lpStr) ? FALSE:TRUE):TRUE)
  19. #define COUNTOF(x) (sizeof(x)/sizeof *(x))
  20. //
  21. // DEBUGGING:
  22. //
  23. #define DBG_NONE 0x0000
  24. #define DBG_INFO 0x0001
  25. #define DBG_WARN 0x0002
  26. #define DBG_WARNING 0x0002
  27. #define DBG_ERROR 0x0004
  28. #define DBG_TRACE 0x0008
  29. #define DBG_SECURITY 0x0010
  30. #define DBG_EXEC 0x0020
  31. #define DBG_PORT 0x0040
  32. #define DBG_NOTIFY 0x0080
  33. #define DBG_PAUSE 0x0100
  34. #define DBG_ASSERT 0x0200
  35. #define DBG_THREADM 0x0400
  36. #define DBG_MIN 0x0800
  37. #define DBG_TIME 0x1000
  38. #define DBG_FOLDER 0x2000
  39. #define DBG_NOHEAD 0x8000
  40. #if DBG
  41. ULONG
  42. DbgPrint(
  43. PCH Format,
  44. ...
  45. );
  46. VOID
  47. DbgBreakPoint(
  48. VOID
  49. );
  50. #define GLOBAL_DEBUG_FLAGS LocalMonDebug
  51. extern DWORD GLOBAL_DEBUG_FLAGS;
  52. /* These flags are not used as arguments to the DBGMSG macro.
  53. * You have to set the high word of the global variable to cause it to break.
  54. * It is ignored if used with DBGMSG.
  55. * (Here mainly for explanatory purposes.)
  56. */
  57. #define DBG_BREAK_ON_WARNING ( DBG_WARNING << 16 )
  58. #define DBG_BREAK_ON_ERROR ( DBG_ERROR << 16 )
  59. /* Double braces are needed for this one, e.g.:
  60. *
  61. * DBGMSG( DBG_ERROR, ( "Error code %d", Error ) );
  62. *
  63. * This is because we can't use variable parameter lists in macros.
  64. * The statement gets pre-processed to a semi-colon in non-debug mode.
  65. *
  66. * Set the global variable GLOBAL_DEBUG_FLAGS via the debugger.
  67. * Setting the flag in the low word causes that level to be printed;
  68. * setting the high word causes a break into the debugger.
  69. * E.g. setting it to 0x00040006 will print out all warning and error
  70. * messages, and break on errors.
  71. */
  72. #define DBGMSG( Level, MsgAndArgs ) \
  73. { \
  74. if( ( Level & 0xFFFF ) & GLOBAL_DEBUG_FLAGS ) \
  75. DbgPrint MsgAndArgs; \
  76. if( ( Level << 16 ) & GLOBAL_DEBUG_FLAGS ) \
  77. DbgBreakPoint(); \
  78. }
  79. #define SPLASSERT(expr) \
  80. if (!(expr)) { \
  81. DbgMsg( L"Failed: %s\nLine %d, %ws\n", \
  82. #expr, \
  83. __LINE__, \
  84. __FILE__ ); \
  85. DebugBreak(); \
  86. }
  87. #else
  88. #define DBGMSG
  89. #define SPLASSERT(expr)
  90. #endif
  91. #endif // _LOCAL_H_