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.

154 lines
4.4 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Common.h
  7. //
  8. // Description:
  9. // Definition of common type, constant and header files.
  10. //
  11. // Author:
  12. // Henry Wang (HenryWa) 24-AUG-1999
  13. // MSP Prabu (mprabu) 04-Dec-2000
  14. // Jim Benton (jbenton) 15-Oct-2001
  15. //
  16. // Notes:
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. #pragma once
  20. #pragma warning( disable : 4786 )
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Include Files
  23. //////////////////////////////////////////////////////////////////////////////
  24. using namespace std;
  25. class CProvBase;
  26. class CObjPath;
  27. class CWbemClassObject;
  28. extern long g_cObj;
  29. extern long g_cLock;
  30. extern HMODULE g_hModule;
  31. typedef LPVOID * PPVOID;
  32. typedef CProvBase * (__stdcall * FPNEW)(
  33. IN LPCWSTR pwszName,
  34. IN CWbemServices * pNamespace
  35. );
  36. void CreateClass(
  37. IN const WCHAR * pwszClassName,
  38. IN CWbemServices * pNamespace,
  39. IN OUT auto_ptr<CProvBase>& rNewClass
  40. );
  41. _bstr_t EncodeQuotes(IN WCHAR * wszString);
  42. BOOL MapVssErrorToMsg(
  43. IN HRESULT hr,
  44. OUT LONG *plMsgNum
  45. ) throw( HRESULT );
  46. LPWSTR GetMsg(
  47. IN LONG msgId,
  48. ...
  49. );
  50. #define GUID_PRINTF_ARG( X ) \
  51. (X).Data1, \
  52. (X).Data2, \
  53. (X).Data3, \
  54. (X).Data4[0], (X).Data4[1], (X).Data4[2], (X).Data4[3], \
  55. (X).Data4[4], (X).Data4[5], (X).Data4[6], (X).Data4[7]
  56. #define IF_WSTR_NULL_THROW( XWSTR, XHR, XMSG ) \
  57. { if ((WCHAR*)XWSTR == NULL || ((WCHAR*)XWSTR)[0] == L'\0') \
  58. { ft.hr = XHR; ft.Throw(VSSDBG_VSSADMIN, ft.hr, XMSG); } }
  59. #define IF_PROP_NULL_THROW( XOBJ, XPROP, XHR, XMSG ) \
  60. { if (XOBJ.IsPropertyNull(XPROP)) \
  61. { ft.hr = XHR; ft.Throw(VSSDBG_VSSADMIN, ft.hr, XMSG); } }
  62. WCHAR* GuidToString(GUID guid);
  63. const int g_cchGUID = 48;
  64. const int g_cchWBEM_MAX_OBJPATH = 520;
  65. const int g_cchWBEM_DATETIME_FORMAT = 26;
  66. const int g_cchMAX_I64DEC_STRING = 22;
  67. //
  68. // wbem
  69. //
  70. extern const WCHAR * const PVD_WBEM_PROVIDERNAME;
  71. extern const WCHAR * const PVD_WBEM_EXTENDEDSTATUS;
  72. extern const WCHAR * const PVD_WBEM_DESCRIPTION;
  73. extern const WCHAR * const PVD_WBEM_STATUSCODE;
  74. extern const WCHAR * const PVD_WBEM_STATUS;
  75. extern const WCHAR * const PVD_WBEM_CLASS;
  76. extern const WCHAR * const PVD_WBEM_RELPATH;
  77. extern const WCHAR * const PVD_WBEM_PROP_ANTECEDENT;
  78. extern const WCHAR * const PVD_WBEM_PROP_DEPENDENT;
  79. extern const WCHAR * const PVD_WBEM_PROP_ELEMENT;
  80. extern const WCHAR * const PVD_WBEM_PROP_SETTING;
  81. extern const WCHAR * const PVD_WBEM_PROP_DEVICEID;
  82. extern const WCHAR * const PVD_WBEM_PROP_RETURNVALUE;
  83. extern const WCHAR * const PVD_WBEM_PROP_PROVIDERNAME;
  84. extern const WCHAR * const PVD_WBEM_QUA_DYNAMIC;
  85. extern const WCHAR * const PVD_WBEM_QUA_CIMTYPE;
  86. //
  87. // Constants used in partial value maps for localization
  88. //
  89. extern const WCHAR * const PVDR_CONS_UNAVAILABLE;
  90. extern const WCHAR * const PVDR_CONS_ENABLED;
  91. extern const WCHAR * const PVDR_CONS_DISABLED;
  92. class CClassData
  93. {
  94. public:
  95. const WCHAR * wszClassName;
  96. FPNEW pfConstruct;
  97. const char * szType;
  98. }; // *** class CClassData
  99. class CClassCreator
  100. {
  101. public:
  102. CClassCreator( void )
  103. : m_pfnConstructor( NULL )
  104. , m_pbstrClassName( L"" )
  105. { };
  106. CClassCreator(
  107. IN FPNEW pfn,
  108. IN const WCHAR * pwszClassName
  109. )
  110. : m_pfnConstructor( pfn )
  111. , m_pbstrClassName( pwszClassName )
  112. { };
  113. FPNEW m_pfnConstructor;
  114. _bstr_t m_pbstrClassName;
  115. }; //*** class CClassCreator
  116. template< class _Ty >
  117. struct strLessThan : binary_function< _Ty, _Ty, bool >
  118. {
  119. bool operator()( const _Ty& _X, const _Ty& _Y ) const
  120. {
  121. return ( _wcsicmp( _X, _Y ) < 0 );
  122. }
  123. }; //*** struct strLessThan
  124. typedef map< _bstr_t, CClassCreator, strLessThan< _bstr_t > > ClassMap;
  125. typedef map< _bstr_t, _bstr_t, strLessThan< _bstr_t > > TypeNameToClass;
  126. extern TypeNameToClass g_TypeNameToClass;
  127. extern ClassMap g_ClassMap;