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.

538 lines
13 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1998
  5. //
  6. // File: kpdesc.h
  7. //
  8. // Contents: Licensed Pack Description Table
  9. //
  10. // History:
  11. //
  12. //---------------------------------------------------------------------------
  13. #ifndef __TLS_KPDESC_H__
  14. #define __TLS_KPDESC_H__
  15. #include "JetBlue.h"
  16. #include "TlsDb.h"
  17. #define LICPACKDESCRECORD_TABLE_SEARCH_KEYPACKID LSKEYPACK_SEARCH_KEYPACKID
  18. #define LICPACKDESCRECORD_TABLE_SEARCH_LANGID LSKEYPACK_SEARCH_LANGID
  19. #define LICPACKDESCRECORD_TABLE_SEARCH_COMPANYNAME LSKEYPACK_SEARCH_COMPANYNAME
  20. #define LICPACKDESCRECORD_TABLE_SEARCH_PRODUCTNAME LSKEYPACK_SEARCH_PRODUCTNAME
  21. #define LICPACKDESCRECORD_TABLE_SEARCH_PRODUCTDESC LSKEYPACK_SEARCH_PRODUCTDESC
  22. #define LICPACKDESCRECORD_TABLE_PROCESS_KEYPACKID LICPACKDESCRECORD_TABLE_SEARCH_KEYPACKID
  23. #define LICPACKDESCRECORD_TABLE_PROCESS_LANGID LICPACKDESCRECORD_TABLE_SEARCH_LANGID
  24. #define LICPACKDESCRECORD_TABLE_PROCESS_COMPANYNAME LICPACKDESCRECORD_TABLE_SEARCH_COMPANYNAME
  25. #define LICPACKDESCRECORD_TABLE_PROCESS_PRODUCTNAME LICPACKDESCRECORD_TABLE_SEARCH_PRODUCTNAME
  26. #define LICPACKDESCRECORD_TABLE_PROCESS_PRODUCTDESC LICPACKDESCRECORD_TABLE_SEARCH_PRODUCTDESC
  27. #define LICPACKDESCRECORD_TABLE_PROCESS_LASTMODIFYTIME 0x80000000
  28. #define LICPACKDESCRECORD_TABLE_PROCESS_ENTRYSTATUS (LICPACKDESCRECORD_TABLE_PROCESS_LASTMODIFYTIME >> 1)
  29. //
  30. // Table definition for KeyPack Desc table
  31. //
  32. typedef TLSReplLicPackDesc LICPACKDESC;
  33. typedef LICPACKDESC* LPLICPACKDESC;
  34. typedef LICPACKDESC* PLICPACKDESC;
  35. typedef LICPACKDESC LICPACKDESCRECORD;
  36. typedef PLICPACKDESC PLICPACKDESCRECORD;
  37. typedef LPLICPACKDESC LPLICPACKDESCRECORD;
  38. #define LICPACKDESCRECORD_TABLE_NAME _TEXT("LICPACKDESCRECORD")
  39. #define LICPACKDESCRECORD_ID_COLUMN _TEXT("InternalKeyPackId")
  40. #define LICPACKDESCRECORD_LANGID _TEXT("LangId")
  41. #define LICPACKDESCRECORD_LASTMODIFYTIME _TEXT("LastModifyTime")
  42. #define LICPACKDESCRECORD_ENTRYSTATUS _TEXT("EntryStatus")
  43. #define LICPACKDESCRECORD_COMPANY_NAME _TEXT("CompanyName")
  44. #define LICPACKDESCRECORD_PRODUCT_NAME _TEXT("ProductName")
  45. #define LICPACKDESCRECORD_PRODUCT_DESC _TEXT("ProductDesc")
  46. //
  47. // LICPACKDESCRECORD_KeyPackId_idx
  48. //
  49. #define LICPACKDESCRECORD_ID_INDEXNAME \
  50. LICPACKDESCRECORD_TABLE_NAME SEPERATOR LICPACKDESCRECORD_ID_COLUMN SEPERATOR INDEXNAME
  51. //
  52. // Primary Index on keyPack ID "+KeyPackId\0"
  53. //
  54. #define LICPACKDESCRECORD_ID_INDEXNAME_INDEXKEY \
  55. INDEX_SORT_ASCENDING LICPACKDESCRECORD_ID_COLUMN INDEX_END_COLNAME
  56. //-------------------------------------------------------------
  57. // Index structure for KeyPack description
  58. //-------------------------------------------------------------
  59. typedef struct __JBKPDescIndexKeyPackId : public JBKeyBase {
  60. //
  61. // Primay Index on KeyPack ID
  62. //
  63. DWORD dwKeyPackId;
  64. static LPCTSTR pszIndexName;
  65. static LPCTSTR pszIndexKey;
  66. //-----------------------------------------------
  67. __JBKPDescIndexKeyPackId(
  68. const LICPACKDESCRECORD& v
  69. ) :
  70. JBKeyBase()
  71. /*++
  72. ++*/
  73. {
  74. *this = v;
  75. }
  76. //-----------------------------------------------
  77. __JBKPDescIndexKeyPackId(
  78. const LICPACKDESCRECORD* v=NULL
  79. ) :
  80. JBKeyBase()
  81. /*++
  82. ++*/
  83. {
  84. if(v)
  85. {
  86. *this = *v;
  87. }
  88. }
  89. //-----------------------------------------------
  90. __JBKPDescIndexKeyPackId&
  91. operator=(const LICPACKDESCRECORD& v) {
  92. dwKeyPackId = v.dwKeyPackId;
  93. SetEmptyValue(FALSE);
  94. return *this;
  95. }
  96. //--------------------------------------------------------
  97. LPCTSTR
  98. GetIndexName()
  99. {
  100. return pszIndexName;
  101. }
  102. //--------------------------------------------------------
  103. LPCTSTR
  104. GetIndexKey()
  105. {
  106. return pszIndexKey;
  107. }
  108. //--------------------------------------------------------
  109. DWORD
  110. GetNumKeyComponents() { return 1; }
  111. //--------------------------------------------------------
  112. BOOL
  113. GetSearchKey(
  114. DWORD dwComponentIndex,
  115. PVOID* pbData,
  116. unsigned long* cbData,
  117. JET_GRBIT* grbit,
  118. DWORD dwSearchParm
  119. )
  120. /*++
  121. ++*/
  122. {
  123. if(dwComponentIndex >= GetNumKeyComponents())
  124. {
  125. JB_ASSERT(FALSE);
  126. return FALSE;
  127. }
  128. *pbData = &(dwKeyPackId);
  129. *cbData = sizeof(dwKeyPackId);
  130. *grbit = JET_bitNewKey;
  131. return TRUE;
  132. }
  133. } TLSKpDescIndexKpId;
  134. //-------------------------------------------------------------
  135. //
  136. // LICPACKDESCRECORD_KeyPackId_LangId_idx
  137. //
  138. #define LICPACKDESCRECORD_ID_LANGID_INDEXNAME \
  139. LICPACKDESCRECORD_TABLE_NAME SEPERATOR LICPACKDESCRECORD_ID_COLUMN SEPERATOR LICPACKDESCRECORD_LANGID SEPERATOR INDEXNAME
  140. //
  141. // "+KeyPackId\0+LangId\0"
  142. //
  143. #define LICPACKDESCRECORD_ID_LANGID_INDEXNAME_INDEXKEY \
  144. INDEX_SORT_ASCENDING LICPACKDESCRECORD_ID_COLUMN INDEX_END_COLNAME \
  145. INDEX_SORT_ASCENDING LICPACKDESCRECORD_LANGID INDEX_END_COLNAME
  146. typedef struct __JBKPDescIndexKeyPackLangId : public JBKeyBase {
  147. //
  148. // Primary index on KeyPack and language Id
  149. //
  150. DWORD dwKeyPackId;
  151. DWORD dwLanguageId;
  152. static LPCTSTR pszIndexName;
  153. static LPCTSTR pszIndexKey;
  154. //---------------------------------------------------
  155. __JBKPDescIndexKeyPackLangId(
  156. const LICPACKDESCRECORD* v=NULL
  157. ) :
  158. JBKeyBase()
  159. /*++
  160. ++*/
  161. {
  162. if(v)
  163. {
  164. *this = *v;
  165. }
  166. }
  167. //---------------------------------------------------
  168. __JBKPDescIndexKeyPackLangId(
  169. const LICPACKDESCRECORD& v
  170. ) :
  171. JBKeyBase()
  172. /*++
  173. ++*/
  174. {
  175. *this = v;
  176. }
  177. //---------------------------------------------------
  178. __JBKPDescIndexKeyPackLangId&
  179. operator=(const LICPACKDESCRECORD& v) {
  180. dwKeyPackId = v.dwKeyPackId;
  181. dwLanguageId = v.dwLanguageId;
  182. SetEmptyValue(FALSE);
  183. return *this;
  184. }
  185. //--------------------------------------------------------
  186. LPCTSTR
  187. GetIndexName()
  188. {
  189. return pszIndexName;
  190. }
  191. //--------------------------------------------------------
  192. LPCTSTR
  193. GetIndexKey()
  194. {
  195. return pszIndexKey;
  196. }
  197. //--------------------------------------------------------
  198. DWORD
  199. GetNumKeyComponents() { return 2; }
  200. //--------------------------------------------------------
  201. BOOL
  202. GetSearchKey(
  203. DWORD dwComponentIndex,
  204. PVOID* pbData,
  205. unsigned long* cbData,
  206. JET_GRBIT* grbit,
  207. DWORD dwSearchParm
  208. )
  209. /*++
  210. ++*/
  211. {
  212. BOOL retCode = TRUE;
  213. if(dwComponentIndex >= GetNumKeyComponents())
  214. {
  215. JB_ASSERT(FALSE);
  216. return FALSE;
  217. }
  218. *cbData = 0;
  219. switch(dwComponentIndex)
  220. {
  221. case 0:
  222. *pbData = &dwKeyPackId;
  223. *cbData = sizeof(dwKeyPackId);
  224. *grbit = JET_bitNewKey;
  225. break;
  226. case 1:
  227. *pbData = &dwLanguageId;
  228. *cbData = sizeof(dwLanguageId);
  229. *grbit = 0;
  230. break;
  231. default:
  232. JB_ASSERT(FALSE);
  233. retCode = FALSE;
  234. break;
  235. }
  236. return retCode;
  237. }
  238. } TLSKpDescIndexKpLangId;
  239. /////////////////////////////////////////////////////////////////////////
  240. // KeyPack_LastModifyTime_idx
  241. //
  242. #define LICPACKDESCRECORD_LASTMODIFYTIME_INDEXNAME \
  243. LICPACKDESCRECORD_TABLE_NAME SEPERATOR LICPACKDESCRECORD_LASTMODIFYTIME SEPERATOR INDEXNAME
  244. //
  245. // Index "+LastModifyTime\0"
  246. //
  247. #define LICPACKDESCRECORD_LASTMODIFYTIME_INDEXNAME_INDEXKEY \
  248. INDEX_SORT_ASCENDING LICPACKDESCRECORD_LASTMODIFYTIME INDEX_END_COLNAME
  249. typedef struct __LICPACKDESCRECORDIdxOnModifyTime : public JBKeyBase {
  250. FILETIME ftLastModifyTime;
  251. static LPCTSTR pszIndexName;
  252. static LPCTSTR pszIndexKey;
  253. //--------------------------------------------------------
  254. __LICPACKDESCRECORDIdxOnModifyTime(
  255. const LICPACKDESCRECORD& v
  256. ) :
  257. JBKeyBase()
  258. /*++
  259. ++*/
  260. {
  261. *this = v;
  262. }
  263. //--------------------------------------------------------
  264. __LICPACKDESCRECORDIdxOnModifyTime(
  265. const LICPACKDESCRECORD* v=NULL
  266. ) :
  267. JBKeyBase()
  268. /*++
  269. ++*/
  270. {
  271. if(v)
  272. {
  273. *this = *v;
  274. }
  275. }
  276. //--------------------------------------------------------
  277. __LICPACKDESCRECORDIdxOnModifyTime&
  278. operator=(const LICPACKDESCRECORD& v) {
  279. ftLastModifyTime = v.ftLastModifyTime;
  280. SetEmptyValue(FALSE);
  281. return *this;
  282. }
  283. //--------------------------------------------------------
  284. LPCTSTR
  285. GetIndexName()
  286. {
  287. return pszIndexName;
  288. }
  289. //--------------------------------------------------------
  290. LPCTSTR
  291. GetIndexKey()
  292. {
  293. return pszIndexKey;
  294. }
  295. //--------------------------------------------------------
  296. DWORD
  297. GetNumKeyComponents() { return 1; }
  298. //--------------------------------------------------------
  299. BOOL
  300. GetSearchKey(
  301. DWORD dwComponentIndex,
  302. PVOID* pbData,
  303. unsigned long* cbData,
  304. JET_GRBIT* grbit,
  305. DWORD dwSearchParm
  306. )
  307. /*++
  308. ++*/
  309. {
  310. if(dwComponentIndex >= GetNumKeyComponents())
  311. {
  312. JB_ASSERT(FALSE);
  313. return FALSE;
  314. }
  315. *pbData = &(ftLastModifyTime);
  316. *cbData = sizeof(ftLastModifyTime);
  317. *grbit = JET_bitNewKey;
  318. return TRUE;
  319. }
  320. } TLSLICPACKDESCRECORDIndexLastModifyTime;
  321. //
  322. ///////////////////////////////////////////////////////////////////////
  323. //
  324. //
  325. ///////////////////////////////////////////////////////////////////////
  326. //
  327. class LicPackDescTable : public TLSTable<LICPACKDESCRECORD>
  328. {
  329. private:
  330. static LPCTSTR pszTableName;
  331. TLSColumnUchar ucEntryStatus;
  332. TLSColumnDword dwKeyPackId;
  333. TLSColumnDword dwLanguageId;
  334. TLSColumnFileTime ftLastModifyTime;
  335. TLSColumnText szCompanyName;
  336. TLSColumnText szProductName;
  337. TLSColumnText szProductDesc;
  338. BOOL
  339. ProcessSingleColumn(
  340. BOOL bFetch,
  341. TLSColumnBase& column,
  342. DWORD offset,
  343. PVOID pbData,
  344. DWORD cbData,
  345. PDWORD pcbDataReturn,
  346. LPCTSTR szColumnName
  347. );
  348. BOOL
  349. ProcessRecord(
  350. LICPACKDESCRECORD* v,
  351. BOOL bFetch, // TRUE - fetch, FALSE insert
  352. DWORD dwParam,
  353. BOOL bUpdate
  354. );
  355. public:
  356. virtual LPCTSTR
  357. GetTableName()
  358. {
  359. return pszTableName;
  360. }
  361. //--------------------------------------------------------
  362. LicPackDescTable(
  363. JBDatabase& database
  364. ) : TLSTable<LICPACKDESCRECORD>(database)
  365. /*
  366. */
  367. {
  368. }
  369. //--------------------------------------------------------
  370. virtual BOOL
  371. ResolveToTableColumn();
  372. //--------------------------------------------------------
  373. virtual BOOL
  374. FetchRecord(
  375. LICPACKDESCRECORD& kpRecord,
  376. DWORD dwParam=PROCESS_ALL_COLUMNS
  377. )
  378. /*
  379. */
  380. {
  381. if(IsValid() == FALSE)
  382. {
  383. DebugOutput(
  384. _TEXT("Table %s is not valid...\n"),
  385. GetTableName()
  386. );
  387. JB_ASSERT(FALSE);
  388. SetLastJetError(JET_errInvalidParameter);
  389. return FALSE;
  390. }
  391. //CCriticalSectionLocker Lock(GetTableLock());
  392. return ProcessRecord(&kpRecord, TRUE, dwParam, FALSE);
  393. }
  394. //--------------------------------------------------------
  395. virtual BOOL
  396. InsertRecord(
  397. LICPACKDESCRECORD& kpRecord,
  398. DWORD dwParam=PROCESS_ALL_COLUMNS
  399. )
  400. /*
  401. */
  402. {
  403. if(IsValid() == FALSE)
  404. {
  405. DebugOutput(
  406. _TEXT("Table %s is not valid...\n"),
  407. GetTableName()
  408. );
  409. JB_ASSERT(FALSE);
  410. SetLastJetError(JET_errInvalidParameter);
  411. return FALSE;
  412. }
  413. //CCriticalSectionLocker Lock(GetTableLock());
  414. return ProcessRecord(&kpRecord, FALSE, dwParam, FALSE);
  415. }
  416. //-------------------------------------------------------
  417. virtual BOOL
  418. UpdateRecord(
  419. LICPACKDESCRECORD& kpRecord,
  420. DWORD dwParam=PROCESS_ALL_COLUMNS
  421. )
  422. /*
  423. */
  424. {
  425. if(IsValid() == FALSE)
  426. {
  427. DebugOutput(
  428. _TEXT("Table %s is not valid...\n"),
  429. GetTableName()
  430. );
  431. JB_ASSERT(FALSE);
  432. SetLastJetError(JET_errInvalidParameter);
  433. return FALSE;
  434. }
  435. //CCriticalSectionLocker Lock(GetTableLock());
  436. return ProcessRecord(&kpRecord, FALSE, dwParam, TRUE);
  437. }
  438. //-------------------------------------------------------
  439. virtual BOOL
  440. Initialize() { return TRUE; }
  441. //-------------------------------------------------------
  442. virtual JBKeyBase*
  443. EnumerationIndex(
  444. IN BOOL bMatchAll,
  445. IN DWORD dwParam,
  446. IN LICPACKDESCRECORD* kpDesc,
  447. IN OUT BOOL* bCompareKey
  448. );
  449. virtual BOOL
  450. EqualValue(
  451. LICPACKDESCRECORD& s1,
  452. LICPACKDESCRECORD& s2,
  453. BOOL bMatchAll,
  454. DWORD dwParam
  455. );
  456. };
  457. #endif