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.

141 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. wmlmacro.h
  5. Abstract:
  6. This file defines macro for an easy wmi tracing.
  7. Author:
  8. gorn
  9. Revision History:
  10. --*/
  11. #ifndef WMLMACRO_H
  12. #define WMLMACRO_H 1
  13. typedef struct {char x[418957];} WMILIBTYPE_STRING;
  14. #undef WMILIB_TYPEDEF
  15. #define WMILIB_TYPEDEF(_TypeName, _EquivType, _FmtStr, _Func, _MofStr, _InitType) \
  16. typedef _EquivType WMILIBTYPE_ ## _TypeName ;
  17. #include "wmltypes.inc"
  18. typedef union _WMLLOCALSTRUCT {
  19. UCHAR uchar;
  20. USHORT ushort;
  21. ULONG uint;
  22. WCHAR wchar;
  23. LONGLONG longlong;
  24. } WMLLOCALSTRUCT;
  25. #define WMLLOCAL WMLLOCALSTRUCT _wmllocal
  26. #define WMILIB_CHECKED_ZERO(_Value, _Type) \
  27. (0 * (1/(int)!(sizeof(_Type) - sizeof(_Value) )))
  28. #define WMILIB_CHECKED_SIZEOF(_Value, _Type) \
  29. (sizeof(_Value) + WMILIB_CHECKED_ZERO( _Value, _Type) )
  30. #define WMILIB_LOGPAIR(_a, _b) (_a),(_b),
  31. #define WMILIB_LOGARGVALTYPE(_value, _type) \
  32. WMILIB_LOGPAIR(WMILIB_CHECKED_SIZEOF(_value, _type), &(_value) )
  33. #define LOG(_TypeName, _Value) \
  34. WMILIB_LOGARGVALTYPE( _Value, WMILIBTYPE_ ## _TypeName)
  35. #define ANULL "$NULL$"
  36. #define WNULL L"$NULL$"
  37. #define LOGASTR(_value) \
  38. WMILIB_LOGPAIR( strlen(_value) + WMILIB_CHECKED_ZERO((_value)[0],CHAR), _value )
  39. #define LOGASTR_CHK(_value) \
  40. WMILIB_LOGPAIR( strlen(_value?_value:ANULL) + WMILIB_CHECKED_ZERO((_value?_value:ANULL)[0],CHAR), _value?_value:ANULL )
  41. #define LOGWSTR(_value) \
  42. WMILIB_LOGPAIR( (wcslen(_value?_value:WNULL)+1) * sizeof(WCHAR) + WMILIB_CHECKED_ZERO((_value?_value:WNULL)[0],WCHAR), _value?_value:WNULL)
  43. #define LOGWSTR_CHK(_value) \
  44. WMILIB_LOGPAIR( (wcslen(_value?_value:WNULL)+1) * sizeof(WCHAR) + WMILIB_CHECKED_ZERO((_value?_value:WNULL)[0],WCHAR), _value?_value:WNULL)
  45. #define LOGCSTR(_x) \
  46. WMILIB_LOGPAIR( sizeof((_x).Length) + WMILIB_CHECKED_ZERO(_x,STRING), &(_x).Length ) \
  47. WMILIB_LOGPAIR( (_x).Length, (_x).Buffer )
  48. #define LOGUSTR(_x) \
  49. WMILIB_LOGPAIR( sizeof((_x).Length) \
  50. + WMILIB_CHECKED_ZERO((_x),UNICODE_STRING), &(_x).Length) \
  51. WMILIB_LOGPAIR( (_x).Length, (_x).Buffer )
  52. #define LOGCHARARR(_count, _x) \
  53. WMILIB_LOGARGVALTYPE( _wmllocal.ushort , USHORT ) \
  54. WMILIB_LOGPAIR( (_wmllocal.ushort = _count * sizeof(CHAR)) \
  55. + WMILIB_CHECKED_ZERO((_x)[0], CHAR), _x )
  56. #define LOGWCHARARR(_count, _x) \
  57. WMILIB_LOGARGVALTYPE( _wmllocal.ushort , USHORT ) \
  58. WMILIB_LOGPAIR( (_wmllocal.ushort = _count * sizeof(WCHAR)) \
  59. + WMILIB_CHECKED_ZERO((_x)[0], WCHAR), _x )
  60. #define LOGTIME(_Value) LOG(TIMENT, _Value)
  61. #define LOGPTR(_Value) LOG(PTR, _Value)
  62. #define LOGHANDLE(_Value) LOG(HANDLE, _Value)
  63. #define LOGSTATUS(_Value) LOG(XINT, _Value)
  64. #define LOGBYTE(_Value) LOG(UBYTE, _Value)
  65. #define LOGULONG(_Value) LOG(UINT, _Value)
  66. #define LOGULONGLONG(_Value) LOG(ULONGLONG, _Value)
  67. #define LOGXLONG(_Value) LOG(XINT, _Value)
  68. #define LOGXSHORT(_Value) LOG(XSHORT, _Value)
  69. #define LOGUCHAR(_Value) LOG(UCHAR, _Value)
  70. #define LOGIRQL(_Value) LOG(UCHAR, _Value)
  71. #define LOGBOOL(_Value) LOG(BOOL, _Value)
  72. #define LOGBOOLEAN(_Value) LOG(BOOLEAN, _Value)
  73. #define LOGARSTR(_Value) LOGASTR(_Value)
  74. #define LOGPNPMN(_Value) LOG(UCHAR, _Value)
  75. #define LOGIOCTL(_Value) LOG(ULONG, _Value)
  76. #define LOGGUID(_Val) LOG(GUID, _Val)
  77. #define LOGVAL(_val) (sizeof(_val)), (&(_val)),
  78. #define WML_FLAGS(_Val) ( (ULONG)(_Val) )
  79. #define WML_STREAM(_Val) ( (ULONG)(_Val) )
  80. #define WML_CONTROL(_prefix, _stream) \
  81. ( _prefix ## _ControlGuids[ WML_STREAM(_stream) ] )
  82. #define WML_ENABLED(_prefix, _stream, _level, _flags) \
  83. (( WML_CONTROL(_prefix, _stream).EnableLevel >= (_level) ) && \
  84. ( WML_CONTROL(_prefix, _stream).EnableFlags & WML_FLAGS(_flags) ))
  85. #define WML_TRACEGUID(_prefix, _stream, _id) \
  86. ( WML_CONTROL(_prefix, _stream).TraceGuids[ WML_GUID(_id) ] )
  87. #define WML_LOG(_prefix, _stream, _level, _flags, _id, _arg) \
  88. do { \
  89. if ( WML_ENABLED(_prefix, _stream, _level, _flags) ) { \
  90. WmlTrace( WML_ID(_id), \
  91. &WML_TRACEGUID(_prefix, _stream, _id) , \
  92. WML_CONTROL(_prefix, _stream).LoggerHandle, _arg); \
  93. } \
  94. } while (0)
  95. #define WML_PRINTF(_prefix, _stream, _level, _flags, _id, _fmtstr, _arg) \
  96. do { \
  97. if ( WML_ENABLED(_prefix, _stream, _level, _flags) ) { \
  98. WmlPrintf( WML_ID(_id), \
  99. &WML_TRACEGUID(_prefix, _stream, _id) , \
  100. WML_CONTROL(_prefix, _stream).LoggerHandle, \
  101. _fmtstr, _arg); \
  102. } \
  103. } while (0)
  104. #endif // WMLMACRO_H