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.

280 lines
6.0 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: version.h
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #ifndef __TLS_VERSION_H__
  13. #define __TLS_VERSION_H__
  14. #include "JetBlue.h"
  15. #include "TlsDb.h"
  16. #define VERSION_TABLE_PROCESS_VERSION 0x00000001
  17. #define VERSION_TABLE_PROCESS_INSTALLID 0x00000002
  18. #define VERSION_TABLE_PROCESS_DOMAINID 0x00000004
  19. //
  20. // Only one row in Version
  21. //
  22. #define VERSION_TABLE_NAME _TEXT("Version")
  23. #define VERSION_TABLE_VERSION _TEXT("DataBaseVersion")
  24. #define VERSION_TABLE_INSTALLID _TEXT("TLSSetupId")
  25. #define VERSION_TABLE_DOMAINID _TEXT("TLSDomainSetupId")
  26. typedef struct __Version : public TLSReplVersion
  27. {
  28. //----------------------------------------------------
  29. __Version()
  30. {
  31. pbDomainSid = NULL;
  32. dwVersion = 0;
  33. cbDomainSid = 0;
  34. memset(szInstallId, 0, sizeof(szInstallId));
  35. }
  36. //----------------------------------------------------
  37. ~__Version()
  38. {
  39. if(pbDomainSid != NULL)
  40. {
  41. FreeMemory(pbDomainSid);
  42. }
  43. }
  44. //----------------------------------------------------
  45. __Version(const __Version& v)
  46. {
  47. *this = v;
  48. }
  49. //----------------------------------------------------
  50. __Version&
  51. operator=(const TLSReplVersion& v)
  52. {
  53. BOOL bSuccess;
  54. dwVersion = v.dwVersion;
  55. _tcscpy(szInstallId, v.szInstallId);
  56. bSuccess = TLSDBCopySid(
  57. v.pbDomainSid,
  58. v.cbDomainSid,
  59. (PSID *)&pbDomainSid,
  60. &cbDomainSid
  61. );
  62. JB_ASSERT(bSuccess == TRUE);
  63. return *this;
  64. }
  65. __Version&
  66. operator=(const __Version& v)
  67. {
  68. BOOL bSuccess;
  69. if(this == &v)
  70. return *this;
  71. dwVersion = v.dwVersion;
  72. _tcscpy(szInstallId, v.szInstallId);
  73. bSuccess = TLSDBCopySid(
  74. v.pbDomainSid,
  75. v.cbDomainSid,
  76. (PSID *)&pbDomainSid,
  77. &cbDomainSid
  78. );
  79. JB_ASSERT(bSuccess == TRUE);
  80. return *this;
  81. }
  82. } TLSVersion;
  83. //
  84. // Index on version ID
  85. //
  86. #define VERSION_ID_INDEXNAME \
  87. VERSION_TABLE_NAME SEPERATOR VERSION_TABLE_VERSION SEPERATOR INDEXNAME
  88. //
  89. // Primary index - "+DataBaseVersion\0"
  90. //
  91. #define VERSION_ID_INDEXNAME_INDEXKEY \
  92. INDEX_SORT_ASCENDING VERSION_TABLE_VERSION INDEX_END_COLNAME
  93. typedef struct __VersionIndexOnVersionId : public JBKeyBase {
  94. static LPCTSTR pszIndexName;
  95. static LPCTSTR pszIndexKey;
  96. DWORD dwVersion;
  97. //-------------------------------------------------
  98. __VersionIndexOnVersionId(
  99. const TLSVersion* v=NULL
  100. ) :
  101. JBKeyBase()
  102. /*++
  103. ++*/
  104. {
  105. if(v)
  106. {
  107. *this = *v;
  108. }
  109. }
  110. //-------------------------------------------------
  111. __VersionIndexOnVersionId(
  112. const TLSVersion& v
  113. ) :
  114. JBKeyBase()
  115. /*++
  116. ++*/
  117. {
  118. *this = v;
  119. }
  120. __VersionIndexOnVersionId&
  121. operator=(const TLSVersion& v) {
  122. dwVersion = v.dwVersion;
  123. SetEmptyValue(FALSE);
  124. return *this;
  125. }
  126. //--------------------------------------------------------
  127. DWORD
  128. GetNumKeyComponents() { return 1; }
  129. inline LPCTSTR
  130. GetIndexName()
  131. {
  132. return pszIndexName;
  133. }
  134. inline LPCTSTR
  135. GetIndexKey()
  136. {
  137. return pszIndexKey;
  138. }
  139. inline BOOL
  140. GetSearchKey(
  141. DWORD dwComponentIndex,
  142. PVOID* pbData,
  143. unsigned long* cbData,
  144. JET_GRBIT* grbit,
  145. DWORD dwSearchParm
  146. )
  147. /*
  148. */
  149. {
  150. if(dwComponentIndex >= GetNumKeyComponents())
  151. {
  152. JB_ASSERT(FALSE);
  153. return FALSE;
  154. }
  155. *pbData = &(dwVersion);
  156. *cbData = sizeof(dwVersion);
  157. *grbit = JET_bitNewKey;
  158. return TRUE;
  159. }
  160. } TLSVersionIndexVersionId;
  161. //----------------------------------------------------------------------
  162. class VersionTable : public TLSTable<TLSVersion> {
  163. static LPCTSTR pszTableName;
  164. public:
  165. TLSColumnDword dwVersion;
  166. TLSColumnText szInstallId;
  167. TLSColumnBinary pbDomainSid;
  168. //------------------------------------------------
  169. virtual LPCTSTR
  170. GetTableName() {
  171. return pszTableName;
  172. }
  173. //------------------------------------------------
  174. VersionTable(
  175. JBDatabase& database
  176. ) : TLSTable<TLSVersion>(database)
  177. /*
  178. */
  179. {
  180. }
  181. //------------------------------------------------
  182. virtual BOOL
  183. ResolveToTableColumn();
  184. //----------------------------------------------------
  185. virtual BOOL
  186. FetchRecord(
  187. TLSVersion& v,
  188. DWORD dwParam=PROCESS_ALL_COLUMNS
  189. );
  190. //----------------------------------------------------
  191. BOOL
  192. InsertUpdateRecord(
  193. TLSVersion* v,
  194. DWORD dwParam=PROCESS_ALL_COLUMNS
  195. );
  196. //----------------------------------------------------
  197. virtual BOOL
  198. InsertRecord(
  199. TLSVersion& v,
  200. DWORD dwParam=PROCESS_ALL_COLUMNS
  201. );
  202. //----------------------------------------------------
  203. virtual BOOL
  204. UpdateRecord(
  205. TLSVersion& v,
  206. DWORD dwParam=PROCESS_ALL_COLUMNS
  207. );
  208. //----------------------------------------------------
  209. virtual BOOL
  210. Initialize() { return TRUE; }
  211. //----------------------------------------------------
  212. virtual JBKeyBase*
  213. EnumerationIndex(
  214. BOOL bMatchAll,
  215. DWORD dwParam,
  216. TLSVersion* pVersion,
  217. BOOL* bCompareKey
  218. );
  219. //----------------------------------------------------
  220. virtual BOOL
  221. EqualValue(
  222. TLSVersion& s1,
  223. TLSVersion& s2,
  224. BOOL bMatchAll,
  225. DWORD dwParam
  226. );
  227. };
  228. #endif