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.

211 lines
4.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: wkspace.h
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #ifndef __TLSDBWORKSPACE_H__
  13. #define __TLSDBWORKSPACE_H__
  14. #include "SrvDef.h"
  15. //
  16. // from TLSDb
  17. //
  18. #include "JBDef.h"
  19. #include "JetBlue.h"
  20. #include "TLSDb.h"
  21. #include "backup.h"
  22. #include "KPDesc.h"
  23. #include "Licensed.h"
  24. #include "licpack.h"
  25. #include "version.h"
  26. #include "workitem.h"
  27. struct __TLSDbWorkSpace;
  28. //
  29. // Temporary define workspace to be 32
  30. //
  31. #define MAX_WORKSPACE 32
  32. typedef CHandlePool<
  33. struct __TlsDbWorkSpace *,
  34. MAX_WORKSPACE
  35. > TLSDbWorkSpacePool;
  36. //---------------------------------------------------------------------------
  37. typedef struct __TlsDbWorkSpace {
  38. // one instance for all session
  39. static JBInstance g_JbInstance;
  40. //------------------------------------------------
  41. //
  42. // JetBlue transaction is session based and no
  43. // two thread can use same session
  44. //
  45. JBSession m_JetSession;
  46. JBDatabase m_JetDatabase;
  47. //
  48. // These table should be kept open
  49. //
  50. LicPackTable m_LicPackTable;
  51. LicensedTable m_LicensedTable;
  52. //
  53. // LicPackDesc table is used by enumeration and
  54. // adding license pack open as necessary.
  55. //
  56. LicPackDescTable m_LicPackDescTable;
  57. //-----------------------------------------------
  58. BOOL
  59. BeginTransaction()
  60. {
  61. BOOL bSuccess;
  62. bSuccess = m_JetDatabase.BeginTransaction();
  63. return bSuccess;
  64. }
  65. //-----------------------------------------------
  66. BOOL
  67. CommitTransaction()
  68. {
  69. BOOL bSuccess;
  70. bSuccess = m_JetDatabase.CommitTransaction();
  71. return bSuccess;
  72. }
  73. //-----------------------------------------------
  74. BOOL
  75. RollbackTransaction()
  76. {
  77. BOOL bSuccess;
  78. bSuccess = m_JetDatabase.RollbackTransaction();
  79. return bSuccess;
  80. }
  81. //-----------------------------------------------
  82. void
  83. Cleanup()
  84. {
  85. m_LicPackTable.Cleanup();
  86. m_LicPackDescTable.Cleanup();
  87. m_LicensedTable.Cleanup();
  88. }
  89. //------------------------------------------------
  90. __TlsDbWorkSpace() :
  91. m_JetSession(g_JbInstance),
  92. m_JetDatabase(m_JetSession),
  93. m_LicPackTable(m_JetDatabase),
  94. m_LicPackDescTable(m_JetDatabase),
  95. m_LicensedTable(m_JetDatabase)
  96. /*
  97. */
  98. {
  99. //
  100. // Force apps to call InitWorkSpace...
  101. //
  102. }
  103. //------------------------------------------------
  104. ~__TlsDbWorkSpace()
  105. {
  106. m_LicPackTable.CloseTable();
  107. m_LicPackDescTable.CloseTable();
  108. m_LicensedTable.CloseTable();
  109. m_JetDatabase.CloseDatabase();
  110. m_JetSession.EndSession();
  111. }
  112. //------------------------------------------------
  113. BOOL
  114. InitWorkSpace(
  115. BOOL bCreateIfNotExist,
  116. LPCTSTR szDatabaseFile,
  117. LPCTSTR szUserName=NULL,
  118. LPCTSTR szPassword=NULL,
  119. IN LPCTSTR szChkPointDirPath=NULL,
  120. IN LPCTSTR szTempDirPath=NULL,
  121. IN BOOL bUpdatable = FALSE
  122. );
  123. } TLSDbWorkSpace, *LPTLSDbWorkSpace, *PTLSDbWorkSpace;
  124. #ifdef __cplusplus
  125. extern "C" {
  126. #endif
  127. BOOL
  128. TLSJbInstanceInit(
  129. IN OUT JBInstance& jbInstance,
  130. IN LPCTSTR pszChkPointDirPath,
  131. IN LPCTSTR pszTempDirPath,
  132. IN LPCTSTR pszLogDirPath
  133. );
  134. TLSDbWorkSpace*
  135. AllocateWorkSpace(
  136. DWORD dwWaitTime
  137. );
  138. void
  139. ReleaseWorkSpace(
  140. PTLSDbWorkSpace *p
  141. );
  142. //
  143. BOOL
  144. InitializeWorkSpacePool(
  145. int num_workspace,
  146. LPCTSTR szDatabaseFile,
  147. LPCTSTR szUserName,
  148. LPCTSTR szPassword,
  149. LPCTSTR szChkPointDirPath,
  150. LPCTSTR szTempDirPath,
  151. LPCTSTR szLogDirPath,
  152. BOOL bUpdatable
  153. );
  154. DWORD
  155. CloseWorkSpacePool();
  156. WorkItemTable*
  157. GetWorkItemStorageTable();
  158. DWORD
  159. GetNumberOfWorkSpaceHandle();
  160. BOOL
  161. TLSGetESEError(
  162. const JET_ERR jetErrCode,
  163. LPTSTR* pszString
  164. );
  165. BOOL
  166. IsValidAllocatedWorkspace(
  167. PTLSDbWorkSpace p
  168. );
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif