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.

120 lines
3.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: debug.h
  7. //
  8. // Contents: Debug definitions that shouldn't be necessary
  9. // in the retail build.
  10. //
  11. // History: 28-Jun-93 WadeR Created
  12. //
  13. // Notes:
  14. //
  15. //--------------------------------------------------------------------------
  16. #ifndef __DEBUG_H__
  17. #define __DEBUG_H__
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. #include <dsysdbg.h>
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #define DEB_T_SOCK 0x00001000
  27. #if DBG
  28. #define DEBUG_SUPPORT
  29. #endif
  30. #ifdef DEBUG_SUPPORT
  31. #undef DEF_INFOLEVEL
  32. #define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  33. DECLARE_DEBUG2(KSupp);
  34. #define KerbPrintKdcName(Level, Name) KerbPrintKdcNameEx(KSuppInfoLevel, (Level), (Name))
  35. #define DebugLog(_x_) KSuppDebugPrint _x_
  36. #else
  37. #define DebugLog(_x_)
  38. #define KerbPrintKdcName(Level, Name)
  39. #endif // DBG
  40. #define MAX_EXPR_LEN 50
  41. ////////////////////////////////////////////////////////////////////
  42. //
  43. // Name: RET_IF_ERROR
  44. //
  45. // Synopsis: Evaluates an expression, returns from the caller if error.
  46. //
  47. // Arguments: l - Error level to print error message at.
  48. // e - expression to evaluate
  49. //
  50. // NOTE: THIS MACRO WILL RETURN FROM THE CALLING FUNCTION ON ERROR!!!!
  51. //
  52. // This will execute the expression (e), and check the return code. If the
  53. // return code indicates a failure, it prints an error message and returns
  54. // from the calling function.
  55. //
  56. #define RET_IF_ERROR(l,e) \
  57. { NTSTATUS X_hr_XX__=(e) ; \
  58. if (!NT_SUCCESS(X_hr_XX__)) { \
  59. DebugLog(( (l), (sizeof( #e ) > MAX_EXPR_LEN)? \
  60. "%s(%d):\n\t %.*s ... == 0x%X\n" \
  61. : \
  62. "%s(%d):\n\t %.*s == 0x%X\n" \
  63. , __FILE__, __LINE__, MAX_EXPR_LEN, #e, X_hr_XX__ )); \
  64. return(X_hr_XX__); \
  65. } \
  66. }
  67. ////////////////////////////////////////////////////////////////////
  68. //
  69. // Name: WARN_IF_ERROR
  70. //
  71. // Synopsis: Evaluates an expression, prints warning if error.
  72. //
  73. // Arguments: l - Error level to print warning at.
  74. // e - expression to evaluate
  75. //
  76. // Notes: This calls DebugLog(()) to print. In retail, it just
  77. // evaluates the expression.
  78. //
  79. #if DBG
  80. #define WARN_IF_ERROR(l,e) \
  81. { NTSTATUS X_hr_XX__=(e) ; \
  82. if (!NT_SUCCESS(X_hr_XX__)) { \
  83. DebugLog(( (l), (sizeof( #e ) > MAX_EXPR_LEN)? \
  84. "%s(%d):\n\t %.*s ... == 0x%X\n" \
  85. : \
  86. "%s(%d):\n\t %.*s == 0x%X\n" \
  87. , __FILE__, __LINE__, MAX_EXPR_LEN, #e, X_hr_XX__ )); \
  88. } \
  89. }
  90. #define D_KerbPrintKdcName(_x_) KerbPrintKdcName _x_
  91. #define D_DebugLog(_x_) DebugLog(_x_)
  92. #else // not DBG
  93. #define WARN_IF_ERROR(l,e) (e)
  94. #define D_KerbPrintKdcName(_x_)
  95. #define D_DebugLog(_x_)
  96. #endif
  97. #endif // __DEBUG_H__