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.

524 lines
12 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. tablefcn.h
  5. Abstract:
  6. Defines the function prototypes for the functions used to access the
  7. Jet database tables.
  8. Include after frsalloc.h
  9. Author:
  10. David Orbits (davidor) - 10-Apr-1997
  11. Revision History:
  12. */
  13. JET_ERR
  14. DbsCreateJetSession(
  15. IN OUT PTHREAD_CTX ThreadCtx
  16. );
  17. JET_ERR
  18. DbsCloseJetSession(
  19. IN PTHREAD_CTX ThreadCtx
  20. );
  21. JET_ERR
  22. DbsInsertTable2(
  23. IN PTABLE_CTX TableCtx
  24. );
  25. JET_ERR
  26. DbsTableMoveFirst(
  27. IN PTHREAD_CTX ThreadCtx,
  28. IN PTABLE_CTX TableCtx,
  29. IN ULONG ReplicaNumber,
  30. IN ULONG RecordIndex
  31. );
  32. JET_ERR
  33. DbsOpenTable0(
  34. IN PTHREAD_CTX ThreadCtx,
  35. IN PTABLE_CTX TableCtx,
  36. IN ULONG ReplicaNumber,
  37. OUT PCHAR TableName,
  38. OUT JET_TABLEID *Tid
  39. );
  40. JET_ERR
  41. DbsOpenReplicaTables (
  42. IN PTHREAD_CTX ThreadCtx,
  43. IN PREPLICA Replica,
  44. IN PREPLICA_THREAD_CTX RtCtx
  45. );
  46. FRS_ERROR_CODE
  47. DbsCloseSessionReplicaTables (
  48. IN PTHREAD_CTX ThreadCtx,
  49. IN OUT PREPLICA Replica
  50. );
  51. JET_ERR
  52. DbsCloseReplicaTables (
  53. IN PTHREAD_CTX ThreadCtx,
  54. IN PREPLICA Replica,
  55. IN PREPLICA_THREAD_CTX RtCtx,
  56. IN BOOL SessionErrorCheck
  57. );
  58. VOID
  59. DbsSetJetColAddr (
  60. IN PTABLE_CTX TableCtx
  61. );
  62. VOID
  63. DbsSetJetColSize(
  64. IN PTABLE_CTX TableCtx
  65. );
  66. NTSTATUS
  67. DbsAllocRecordStorage(
  68. IN OUT PTABLE_CTX TableCtx
  69. );
  70. JET_ERR
  71. DbsCheckSetRetrieveErrors(
  72. IN OUT PTABLE_CTX TableCtx
  73. );
  74. #if DBG
  75. VOID
  76. DbsDisplayRecord(
  77. IN ULONG Severity,
  78. IN PTABLE_CTX TableCtx,
  79. IN BOOL Read,
  80. IN PCHAR Debsub,
  81. IN ULONG uLineNo,
  82. IN PULONG RecordFieldx,
  83. IN ULONG FieldCount
  84. );
  85. #endif DBG
  86. JET_ERR
  87. DbsRecordOperation(
  88. IN PTHREAD_CTX ThreadCtx,
  89. IN ULONG Operation,
  90. IN PVOID KeyValue,
  91. IN ULONG RecordIndex,
  92. IN PTABLE_CTX TableCtx
  93. );
  94. ULONG
  95. DbsRecordOperationMKey(
  96. IN PTHREAD_CTX ThreadCtx,
  97. IN ULONG Operation,
  98. IN PVOID *KeyValueArray,
  99. IN ULONG RecordIndex,
  100. IN PTABLE_CTX TableCtx
  101. );
  102. JET_ERR
  103. DbsWriteReplicaTableRecord(
  104. IN PTHREAD_CTX ThreadCtx,
  105. IN ULONG ReplicaNumber,
  106. IN PTABLE_CTX TableCtx
  107. );
  108. ULONG
  109. DbsWriteTableField(
  110. IN PTHREAD_CTX ThreadCtx,
  111. IN ULONG ReplicaNumber,
  112. IN PTABLE_CTX TableCtx,
  113. IN ULONG RecordFieldx
  114. );
  115. ULONG
  116. DbsWriteTableFieldMult(
  117. IN PTHREAD_CTX ThreadCtx,
  118. IN ULONG ReplicaNumber,
  119. IN PTABLE_CTX TableCtx,
  120. IN PULONG RecordFieldx,
  121. IN ULONG FieldCount
  122. );
  123. PVOID
  124. DbsDataExtensionFind(
  125. IN PVOID ExtBuf,
  126. IN DATA_EXTENSION_TYPE_CODES TypeCode
  127. );
  128. VOID
  129. DbsDataInitCocExtension(
  130. IN PCHANGE_ORDER_RECORD_EXTENSION CocExt
  131. );
  132. VOID
  133. DbsDataInitIDTableExtension(
  134. IN PIDTABLE_RECORD_EXTENSION IdtExt
  135. );
  136. DWORD
  137. FrsGetOrSetFileObjectId(
  138. IN HANDLE Handle,
  139. IN LPCWSTR FileName,
  140. IN BOOL CallerSupplied,
  141. OUT PFILE_OBJECTID_BUFFER ObjectIdBuffer
  142. );
  143. ULONG
  144. ChgOrdInboundRetired(
  145. IN PCHANGE_ORDER_ENTRY ChangeOrder
  146. );
  147. ULONG
  148. ChgOrdInboundRetry(
  149. IN PCHANGE_ORDER_ENTRY ChangeOrder,
  150. IN ULONG NewState
  151. );
  152. //
  153. // DB Service access functions.
  154. //
  155. VOID
  156. DbsInitialize(
  157. VOID
  158. );
  159. VOID
  160. DbsShutDown(
  161. VOID
  162. );
  163. PTABLE_CTX
  164. DbsCreateTableContext(
  165. IN ULONG TableType
  166. );
  167. ULONG
  168. DbsOpenTable(
  169. IN PTHREAD_CTX ThreadCtx,
  170. IN PTABLE_CTX TableCtx,
  171. IN ULONG ReplicaNumber,
  172. IN ULONG TableType,
  173. IN PVOID DataRecord
  174. );
  175. BOOL
  176. DbsFreeTableContext(
  177. IN PTABLE_CTX TableCtx,
  178. IN JET_SESID Sesid
  179. );
  180. PCOMMAND_PACKET
  181. DbsPrepareCmdPkt (
  182. PCOMMAND_PACKET CmdPkt,
  183. PREPLICA Replica,
  184. ULONG CmdRequest,
  185. PTABLE_CTX TableCtx,
  186. PVOID CallContext,
  187. ULONG TableType,
  188. ULONG AccessRequest,
  189. ULONG IndexType,
  190. PVOID KeyValue,
  191. ULONG KeyValueLength,
  192. BOOL Submit
  193. );
  194. ULONG
  195. DbsInitializeIDTableRecord(
  196. IN OUT PTABLE_CTX TableCtx,
  197. IN HANDLE FileHandle,
  198. IN PREPLICA Replica,
  199. IN PCHANGE_ORDER_ENTRY ChangeOrder,
  200. IN PWCHAR FileName,
  201. IN OUT BOOL *ExistingOid
  202. );
  203. VOID
  204. DbsDBInitConfigRecord(
  205. IN PTABLE_CTX TableCtx,
  206. IN GUID *ReplicaSetGuid,
  207. IN PWCHAR ReplicaSetName,
  208. IN ULONG ReplicaNumber,
  209. IN PWCHAR ReplicaRootPath,
  210. IN PWCHAR ReplicaStagingPath,
  211. IN PWCHAR ReplicaVolume
  212. );
  213. ULONG
  214. DbsFidToGuid(
  215. IN PTHREAD_CTX ThreadCtx,
  216. IN PREPLICA Replica,
  217. IN PTABLE_CTX TableCtx,
  218. IN PULONGLONG Fid,
  219. OUT GUID *Guid
  220. );
  221. ULONG
  222. DbsGuidToFid(
  223. IN PTHREAD_CTX ThreadCtx,
  224. IN PREPLICA Replica,
  225. IN PTABLE_CTX TableCtx,
  226. IN GUID *Guid,
  227. OUT PULONGLONG Fid
  228. );
  229. ULONG
  230. DbsInitOneReplicaSet(
  231. PREPLICA Replica
  232. );
  233. ULONG
  234. DbsFreeRtCtx(
  235. IN PTHREAD_CTX ThreadCtx,
  236. IN PREPLICA Replica,
  237. IN PREPLICA_THREAD_CTX RtCtx,
  238. IN BOOL SessionErrorCheck
  239. );
  240. JET_ERR
  241. DbsDeleteTableRecord(
  242. IN PTABLE_CTX TableCtx
  243. );
  244. ULONG
  245. DbsDeleteTableRecordByIndex(
  246. IN PTHREAD_CTX ThreadCtx,
  247. IN PREPLICA Replica,
  248. IN PTABLE_CTX TableCtx,
  249. IN PVOID pIndex,
  250. IN ULONG IndexType,
  251. IN ULONG TableType
  252. );
  253. #define DbsDeleteIDTableRecord(_ThreadCtx_, _Replica_, _TableCtx_, _pIndex_) \
  254. DbsDeleteTableRecordByIndex(_ThreadCtx_, \
  255. _Replica_, \
  256. _TableCtx_, \
  257. _pIndex_, \
  258. GuidIndexx, \
  259. IDTablex)
  260. #define DbsDeleteDIRTableRecord(_ThreadCtx_, _Replica_, _TableCtx_, _pIndex_) \
  261. DbsDeleteTableRecordByIndex(_ThreadCtx_, \
  262. _Replica_, \
  263. _TableCtx_, \
  264. _pIndex_, \
  265. DFileGuidIndexx, \
  266. DIRTablex)
  267. ULONG
  268. DbsReadTableRecordByIndex(
  269. IN PTHREAD_CTX ThreadCtx,
  270. IN PREPLICA Replica,
  271. IN PTABLE_CTX TableCtx,
  272. IN PVOID pIndex,
  273. IN ULONG IndexType,
  274. IN ULONG TableType
  275. );
  276. ULONG
  277. DbsUpdateTableRecordByIndex(
  278. IN PTHREAD_CTX ThreadCtx,
  279. IN PREPLICA Replica,
  280. IN PTABLE_CTX TableCtx,
  281. IN PVOID pIndex,
  282. IN ULONG IndexType,
  283. IN ULONG TableType
  284. );
  285. ULONG
  286. DbsInsertTable(
  287. IN PTHREAD_CTX ThreadCtx,
  288. IN PREPLICA Replica,
  289. IN PTABLE_CTX TableCtx,
  290. IN ULONG TableType,
  291. IN PVOID DataRecord
  292. );
  293. ULONG
  294. DbsTableMoveToRecord(
  295. IN PTHREAD_CTX ThreadCtx,
  296. IN PTABLE_CTX TableCtx,
  297. IN ULONG RecordIndex,
  298. IN ULONG MoveArg
  299. );
  300. #define FrsMoveFirst JET_MoveFirst
  301. #define FrsMovePrevious JET_MovePrevious
  302. #define FrsMoveNext JET_MoveNext
  303. #define FrsMoveLast JET_MoveLast
  304. ULONG
  305. DbsTableRead(
  306. IN PTHREAD_CTX ThreadCtx,
  307. IN PTABLE_CTX TableCtx
  308. );
  309. ULONG
  310. DbsUpdateRecordField(
  311. IN PTHREAD_CTX ThreadCtx,
  312. IN PREPLICA Replica,
  313. IN PTABLE_CTX TableCtx,
  314. IN ULONG IndexField,
  315. IN PVOID IndexValue,
  316. IN ULONG UpdateField
  317. );
  318. ULONG
  319. DbsRequestSaveMark(
  320. PVOLUME_MONITOR_ENTRY pVme,
  321. BOOL Wait
  322. );
  323. ULONG
  324. DbsRequestReplicaServiceStateSave(
  325. IN PREPLICA Replica,
  326. IN BOOL Wait
  327. );
  328. ULONG
  329. DbsUpdateVV(
  330. IN PTHREAD_CTX ThreadCtx,
  331. IN PREPLICA Replica,
  332. IN PREPLICA_THREAD_CTX RtCtx,
  333. IN ULONGLONG OriginatorVsn,
  334. IN GUID *OriginatorGuid
  335. );
  336. //
  337. // An enumerate table function is passed as a parameter to FrsEnumerateTable().
  338. // It gets a PTHREAD_CTX, PTABLE_CTX and a pointer to a data record from the
  339. // table. It does its processing of the record data and returns a JET_ERR
  340. // status. If the status is JET_errSuccess it will be called with the next
  341. // record in the table. IF the status is NOT JET_errSuccess, that status is
  342. // returned as the status result of the FrsEnumerateTable() function. If
  343. // the status is JET_errInvalidObject then re-read the record and call the table
  344. // function again.
  345. //
  346. //
  347. typedef
  348. JET_ERR
  349. (NTAPI *PENUMERATE_TABLE_ROUTINE) (
  350. IN PTHREAD_CTX ThreadCtx,
  351. IN PTABLE_CTX TableCtx,
  352. IN PVOID Record,
  353. IN PVOID Context
  354. );
  355. typedef
  356. JET_ERR
  357. (NTAPI *PENUMERATE_TABLE_PREREAD) (
  358. IN PTHREAD_CTX ThreadCtx,
  359. IN PTABLE_CTX TableCtx,
  360. IN PVOID Context
  361. );
  362. typedef
  363. JET_ERR
  364. (NTAPI *PENUMERATE_OUTLOGTABLE_ROUTINE) (
  365. IN PTHREAD_CTX ThreadCtx,
  366. IN PTABLE_CTX TableCtx,
  367. IN PCHANGE_ORDER_COMMAND CoCmd,
  368. IN PVOID Context,
  369. IN ULONG OutLogSeqNumber
  370. );
  371. JET_ERR
  372. DbsEnumerateTable2(
  373. IN PTHREAD_CTX ThreadCtx,
  374. IN PTABLE_CTX TableCtx,
  375. IN ULONG RecordIndex,
  376. IN PENUMERATE_TABLE_ROUTINE RecordFunction,
  377. IN PVOID Context,
  378. IN PENUMERATE_TABLE_PREREAD PreReadFunction
  379. );
  380. #define FrsEnumerateTable(_TH, _TC, _RI, _RF, _CTX) \
  381. DbsEnumerateTable2(_TH, _TC, _RI, _RF, _CTX, NULL)
  382. //
  383. // An enumerate directory function is passed as a parameter to
  384. // FrsEnumerateDirectory().
  385. //
  386. // The function gets a the directory handle and a pointer to a directory
  387. // record from the directory. It does its processing of the directory
  388. // data and returns a WIN32 STATUS. If the status is ERROR_SUCCESS it
  389. // will be called with the next record in the directory. IF the status
  390. // is NOT ERROR_SUCCESS, that status is returned as the status result of
  391. // the FrsEnumerateDirectory() function and enumeration stops.
  392. //
  393. // The function is responsible for recursing into the next level of
  394. // directory by calling FrsEnumerateDirectoryRecurse() as needed.
  395. //
  396. // FrsEnumerateDirectory() will continue an enumeration even if
  397. // errors occur if ENUMERATE_DIRECTORY_FLAGS_ERROR_CONTINUE is set.
  398. //
  399. // FrsEnumerateDirectory() will skip non-directory entries if
  400. // if ENUMERATE_DIRECTORY_FLAGS_DIRECTORIES_ONLY is set.
  401. //
  402. #define ENUMERATE_DIRECTORY_FLAGS_NONE (0x00000000)
  403. #define ENUMERATE_DIRECTORY_FLAGS_ERROR_CONTINUE (0x00000001)
  404. #define ENUMERATE_DIRECTORY_FLAGS_DIRECTORIES_ONLY (0x00000002)
  405. typedef
  406. DWORD
  407. (NTAPI *PENUMERATE_DIRECTORY_ROUTINE) (
  408. IN HANDLE DirectoryHandle,
  409. IN PWCHAR DirectoryName,
  410. IN DWORD DirectoryLevel,
  411. IN PFILE_DIRECTORY_INFORMATION DirectoryRecord,
  412. IN DWORD DirectoryFlags,
  413. IN PWCHAR FileName,
  414. IN PVOID Context
  415. );
  416. DWORD
  417. FrsEnumerateDirectoryDeleteWorker(
  418. IN HANDLE DirectoryHandle,
  419. IN PWCHAR DirectoryName,
  420. IN DWORD DirectoryLevel,
  421. IN PFILE_DIRECTORY_INFORMATION DirectoryRecord,
  422. IN DWORD DirectoryFlags,
  423. IN PWCHAR FileName,
  424. IN PVOID Ignored
  425. );
  426. DWORD
  427. FrsEnumerateDirectoryRecurse(
  428. IN HANDLE DirectoryHandle,
  429. IN PWCHAR DirectoryName,
  430. IN DWORD DirectoryLevel,
  431. IN PFILE_DIRECTORY_INFORMATION DirectoryRecord,
  432. IN DWORD DirectoryFlags,
  433. IN PWCHAR FileName,
  434. IN HANDLE FileHandle,
  435. IN PVOID Context,
  436. IN PENUMERATE_DIRECTORY_ROUTINE Function
  437. );
  438. DWORD
  439. FrsEnumerateDirectory(
  440. IN HANDLE DirectoryHandle,
  441. IN PWCHAR DirectoryName,
  442. IN DWORD DirectoryLevel,
  443. IN DWORD DirectoryFlags,
  444. IN PVOID Context,
  445. IN PENUMERATE_DIRECTORY_ROUTINE Function
  446. );