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.

306 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. mb.hxx
  5. Abstract:
  6. This module defines the USER-level wrapper class for access to the
  7. metabase
  8. Author:
  9. JohnL 09-Oct-1996
  10. Environment:
  11. Win32 - User Mode
  12. Project:
  13. Internet Server DLL
  14. Revision History:
  15. --*/
  16. #ifndef _MB_HXX_
  17. #define _MB_HXX_
  18. #if !defined( dllexp)
  19. #define dllexp __declspec( dllexport)
  20. #endif // !defined( dllexp)
  21. #include <string.hxx>
  22. #include <multisz.hxx>
  23. /************************************************************
  24. * Type Definitions
  25. ************************************************************/
  26. //
  27. // Simple wrapper class around the metabase APIs
  28. //
  29. // The Metabase Interface pointer is assumed to remain valid for the lifetime
  30. // of this object.
  31. //
  32. // The character counts for paths should include the terminating '\0'.
  33. //
  34. //
  35. class MB
  36. {
  37. public:
  38. dllexp MB( IMDCOM * pMBCom );
  39. dllexp ~MB( VOID );
  40. BOOL Open( const CHAR * pszPath,
  41. DWORD dwFlags = METADATA_PERMISSION_READ )
  42. {
  43. return Open( METADATA_MASTER_ROOT_HANDLE,
  44. pszPath,
  45. dwFlags );
  46. }
  47. dllexp
  48. BOOL Open( METADATA_HANDLE hOpenRoot,
  49. const CHAR * pszPath,
  50. DWORD dwFlags = METADATA_PERMISSION_READ );
  51. dllexp
  52. BOOL GetAll( const CHAR * pszPath,
  53. DWORD dwFlags,
  54. DWORD dwUserType,
  55. BUFFER * pBuff,
  56. DWORD * pcRecords,
  57. DWORD * pdwDataSetNumber );
  58. dllexp
  59. BOOL GetDataSetNumber( const CHAR * pszPath,
  60. DWORD * pdwDataSetNumber );
  61. dllexp
  62. BOOL EnumObjects( const CHAR * pszPath,
  63. CHAR * Name,
  64. DWORD Index );
  65. dllexp
  66. BOOL AddObject( const CHAR * pszPath );
  67. dllexp
  68. BOOL DeleteObject( const CHAR * pszPath );
  69. dllexp
  70. BOOL
  71. ReferenceData(
  72. const CHAR * pszPath,
  73. DWORD dwPropID,
  74. DWORD dwUserType,
  75. DWORD dwDataType,
  76. VOID * * ppvData,
  77. DWORD * pcbData,
  78. DWORD * pdwTag,
  79. DWORD dwFlags = METADATA_INHERIT | METADATA_REFERENCE
  80. );
  81. dllexp
  82. BOOL ReleaseReferenceData( DWORD dwTag );
  83. dllexp
  84. BOOL Save( VOID );
  85. dllexp
  86. BOOL GetSystemChangeNumber( DWORD *pdwChangeNumber );
  87. BOOL SetDword( const CHAR * pszPath,
  88. DWORD dwPropID,
  89. DWORD dwUserType,
  90. DWORD dwValue,
  91. DWORD dwFlags = METADATA_INHERIT )
  92. {
  93. return SetData( pszPath,
  94. dwPropID,
  95. dwUserType,
  96. DWORD_METADATA,
  97. (PVOID) &dwValue,
  98. sizeof( DWORD ),
  99. dwFlags );
  100. }
  101. BOOL SetString( const CHAR * pszPath,
  102. DWORD dwPropID,
  103. DWORD dwUserType,
  104. CHAR * pszValue,
  105. DWORD dwFlags = METADATA_INHERIT )
  106. {
  107. return SetData( pszPath,
  108. dwPropID,
  109. dwUserType,
  110. STRING_METADATA,
  111. pszValue,
  112. 0, // string length ignored for inprocess clients
  113. dwFlags );
  114. }
  115. BOOL SetMultiSZ( const CHAR * pszPath,
  116. DWORD dwPropID,
  117. DWORD dwUserType,
  118. CHAR * pszValue,
  119. DWORD dwFlags = METADATA_INHERIT )
  120. {
  121. return SetData( pszPath,
  122. dwPropID,
  123. dwUserType,
  124. MULTISZ_METADATA,
  125. pszValue,
  126. 0, // string length ignored for inprocess clients
  127. dwFlags );
  128. }
  129. BOOL GetDword( const CHAR * pszPath,
  130. DWORD dwPropID,
  131. DWORD dwUserType,
  132. DWORD * pdwValue,
  133. DWORD dwFlags = METADATA_INHERIT )
  134. {
  135. DWORD cb = sizeof(DWORD);
  136. return GetData( pszPath,
  137. dwPropID,
  138. dwUserType,
  139. DWORD_METADATA,
  140. pdwValue,
  141. &cb,
  142. dwFlags );
  143. }
  144. VOID GetDword( const CHAR * pszPath,
  145. DWORD dwPropID,
  146. DWORD dwUserType,
  147. DWORD dwDefaultValue,
  148. DWORD * pdwValue,
  149. DWORD dwFlags = METADATA_INHERIT
  150. )
  151. {
  152. DWORD cb = sizeof(DWORD);
  153. if ( !GetData( pszPath,
  154. dwPropID,
  155. dwUserType,
  156. DWORD_METADATA,
  157. pdwValue,
  158. &cb,
  159. dwFlags )
  160. ) {
  161. *pdwValue = dwDefaultValue;
  162. }
  163. }
  164. BOOL GetString( const CHAR * pszPath,
  165. DWORD dwPropID,
  166. DWORD dwUserType,
  167. CHAR * pszValue,
  168. DWORD * pcbValue,
  169. DWORD dwFlags = METADATA_INHERIT )
  170. {
  171. return GetData( pszPath,
  172. dwPropID,
  173. dwUserType,
  174. STRING_METADATA,
  175. pszValue,
  176. pcbValue,
  177. dwFlags );
  178. }
  179. dllexp
  180. BOOL GetStr( const CHAR * pszPath,
  181. DWORD dwPropID,
  182. DWORD dwUserType,
  183. STR * strValue,
  184. DWORD dwFlags = METADATA_INHERIT,
  185. const CHAR * pszDefault = NULL );
  186. BOOL GetBuffer( const CHAR* pszPath,
  187. DWORD dwPropID,
  188. DWORD dwUserType,
  189. BUFFER* pbu,
  190. LPDWORD pdwL,
  191. DWORD dwFlags = METADATA_INHERIT )
  192. {
  193. *pdwL = pbu->QuerySize();
  194. TryAgain:
  195. if ( GetData( pszPath,
  196. dwPropID,
  197. dwUserType,
  198. BINARY_METADATA,
  199. pbu->QueryPtr(),
  200. pdwL,
  201. dwFlags ) )
  202. {
  203. return TRUE;
  204. }
  205. else if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
  206. pbu->Resize( *pdwL ) )
  207. {
  208. goto TryAgain;
  209. }
  210. return FALSE;
  211. }
  212. dllexp
  213. BOOL GetMultisz( const CHAR * pszPath,
  214. DWORD dwPropID,
  215. DWORD dwUserType,
  216. MULTISZ * multiszValue,
  217. DWORD dwFlags = METADATA_INHERIT );
  218. dllexp
  219. BOOL SetData( const CHAR * pszPath,
  220. DWORD dwPropID,
  221. DWORD dwUserType,
  222. DWORD dwDataType,
  223. VOID * pvData,
  224. DWORD cbData,
  225. DWORD dwFlags = METADATA_INHERIT );
  226. dllexp
  227. BOOL GetData( const CHAR * pszPath,
  228. DWORD dwPropID,
  229. DWORD dwUserType,
  230. DWORD dwDataType,
  231. VOID * pvData,
  232. DWORD * cbData,
  233. DWORD dwFlags = METADATA_INHERIT );
  234. dllexp
  235. BOOL DeleteData(const CHAR * pszPath,
  236. DWORD dwPropID,
  237. DWORD dwUserType,
  238. DWORD dwDataType );
  239. dllexp
  240. BOOL GetDataPaths(const CHAR * pszPath,
  241. DWORD dwPropID,
  242. DWORD dwDataType,
  243. BUFFER * pBuff );
  244. dllexp
  245. BOOL Close( VOID );
  246. METADATA_HANDLE QueryHandle( VOID ) const
  247. { return _hMB; }
  248. IMDCOM *QueryPMDCOM( VOID ) const
  249. { return _pMBCom; }
  250. private:
  251. IMDCOM * _pMBCom;
  252. METADATA_HANDLE _hMB;
  253. };
  254. #endif // _MB_HXX_