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.

132 lines
4.6 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 LOGASTR(_value) \
  36. WMILIB_LOGPAIR( strlen(_value) + WMILIB_CHECKED_ZERO((_value)[0],CHAR), _value )
  37. #define LOGWSTR(_value) \
  38. WMILIB_LOGPAIR( wcslen(_value) * sizeof(WCHAR) + WMILIB_CHECKED_ZERO((_value)[0],WCHAR), _value)
  39. #define LOGCSTR(_x) \
  40. WMILIB_LOGPAIR( sizeof((_x).Length) + WMILIB_CHECKED_ZERO(_x,STRING), &(_x).Length ) \
  41. WMILIB_LOGPAIR( (_x).Length, (_x).Buffer )
  42. #define LOGUSTR(_x) \
  43. WMILIB_LOGPAIR( sizeof((_x).Length) \
  44. + WMILIB_CHECKED_ZERO((_x),UNICODE_STRING), &(_x).Length) \
  45. WMILIB_LOGPAIR( (_x).Length, (_x).Buffer )
  46. #define LOGCHARARR(_count, _x) \
  47. WMILIB_LOGARGVALTYPE( _wmllocal.ushort , USHORT ) \
  48. WMILIB_LOGPAIR( (_wmllocal.ushort = _count * sizeof(CHAR)) \
  49. + WMILIB_CHECKED_ZERO((_x)[0], CHAR), _x )
  50. #define LOGWCHARARR(_count, _x) \
  51. WMILIB_LOGARGVALTYPE( _wmllocal.ushort , USHORT ) \
  52. WMILIB_LOGPAIR( (_wmllocal.ushort = _count * sizeof(WCHAR)) \
  53. + WMILIB_CHECKED_ZERO((_x)[0], WCHAR), _x )
  54. #define LOGTIME(_Value) LOG(TIMENT, _Value)
  55. #define LOGPTR(_Value) LOG(PTR, _Value)
  56. #define LOGHANDLE(_Value) LOG(HANDLE, _Value)
  57. #define LOGSTATUS(_Value) LOG(XINT, _Value)
  58. #define LOGBYTE(_Value) LOG(UBYTE, _Value)
  59. #define LOGULONG(_Value) LOG(UINT, _Value)
  60. #define LOGULONGLONG(_Value) LOG(ULONGLONG, _Value)
  61. #define LOGXLONG(_Value) LOG(XINT, _Value)
  62. #define LOGXSHORT(_Value) LOG(XSHORT, _Value)
  63. #define LOGUCHAR(_Value) LOG(UCHAR, _Value)
  64. #define LOGIRQL(_Value) LOG(UCHAR, _Value)
  65. #define LOGBOOL(_Value) LOG(BOOL, _Value)
  66. #define LOGBOOLEAN(_Value) LOG(BOOLEAN, _Value)
  67. #define LOGARSTR(_Value) LOGASTR(_Value)
  68. #define LOGPNPMN(_Value) LOG(UCHAR, _Value)
  69. #define LOGIOCTL(_Value) LOG(ULONG, _Value)
  70. #define LOGGUID(_Val) LOG(GUID, _Val)
  71. #define LOGVAL(_val) (sizeof(_val)), (&(_val)),
  72. #define WML_FLAGS(_Val) ( (ULONG)(_Val) )
  73. #define WML_STREAM(_Val) ( (ULONG)(_Val) )
  74. #define WML_CONTROL(_prefix, _stream) \
  75. ( _prefix ## ControlGuids[ WML_STREAM(_stream) ] )
  76. #define WML_ENABLED(_prefix, _stream, _level, _flags) \
  77. (( WML_CONTROL(_prefix, _stream).EnableLevel >= (_level) ) && \
  78. ( WML_CONTROL(_prefix, _stream).EnableFlags & WML_FLAGS(_flags) ))
  79. #define WML_TRACEGUID(_prefix, _stream, _id) \
  80. ( WML_CONTROL(_prefix, _stream).TraceGuids[ WML_GUID(_id) ] )
  81. #define WML_LOG(_prefix, _stream, _level, _flags, _id, _arg) \
  82. do { \
  83. if ( WML_ENABLED(_prefix, _stream, _level, _flags) ) { \
  84. WmlTrace( WML_ID(_id), \
  85. &WML_TRACEGUID(_prefix, _stream, _id) , \
  86. WML_CONTROL(_prefix, _stream).LoggerHandle, _arg); \
  87. } \
  88. } while (0)
  89. #define WML_PRINTF(_prefix, _stream, _level, _flags, _id, _fmtstr, _arg) \
  90. do { \
  91. if ( WML_ENABLED(_prefix, _stream, _level, _flags) ) { \
  92. WmlPrintf( WML_ID(_id), \
  93. &WML_TRACEGUID(_prefix, _stream, _id) , \
  94. WML_CONTROL(_prefix, _stream).LoggerHandle, \
  95. _fmtstr, _arg); \
  96. } \
  97. } while (0)
  98. #endif // WMLMACRO_H