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.

492 lines
12 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: ulist.hxx
  7. //
  8. // Contents: Update list definitions
  9. //
  10. // Classes: CUpdate
  11. // CUpdateList
  12. //
  13. // History: 15-Jan-92 DrewB Created
  14. //
  15. //---------------------------------------------------------------
  16. #ifndef __ULIST_HXX__
  17. #define __ULIST_HXX__
  18. #include <dfmsp.hxx>
  19. #include <wchar.h>
  20. #include <tset.hxx>
  21. // Update list flags
  22. // STGTY_* are used for types
  23. #define ULF_TYPEFLAGS (STGTY_STORAGE | STGTY_STREAM)
  24. class CUpdate;
  25. SAFE_DFBASED_PTR(CBasedUpdatePtr, CUpdate);
  26. //+--------------------------------------------------------------
  27. //
  28. // Class: CUpdate (ud)
  29. //
  30. // Purpose: Tracks renames and deletions
  31. //
  32. // Interface: See below
  33. //
  34. // History: 15-Jan-92 DrewB Created
  35. //
  36. //---------------------------------------------------------------
  37. class CUpdate : CMallocBased
  38. {
  39. public:
  40. CUpdate(CDfName const *pdfnCurrentName,
  41. CDfName const *pdfnOriginalName,
  42. DFLUID dlLUID,
  43. DWORD dwFlags,
  44. PTSetMember *ptsm);
  45. ~CUpdate(void);
  46. inline CDfName *GetCurrentName(void);
  47. inline CDfName *GetOriginalName(void);
  48. inline DFLUID GetLUID(void) const;
  49. inline DWORD GetFlags(void) const;
  50. inline PTSetMember *GetXSM(void) const;
  51. inline CUpdate *GetNext(void) const;
  52. inline CUpdate *GetPrev(void) const;
  53. inline BOOL IsDelete(void) const;
  54. inline BOOL IsRename(void) const;
  55. inline BOOL IsCreate(void) const;
  56. inline void SetCurrentName(CDfName const *pdfn);
  57. inline void SetOriginalName(CDfName const *pdfn);
  58. inline void SetLUID(DFLUID dl);
  59. inline void SetFlags(DWORD dwFlags);
  60. inline void SetXSM(PTSetMember *ptsm);
  61. inline void SetNext(CUpdate *pud);
  62. inline void SetPrev(CUpdate *pud);
  63. private:
  64. friend class CUpdateList;
  65. CDfName _dfnCurrent;
  66. CDfName _dfnOriginal;
  67. DFLUID _dl;
  68. DWORD _dwFlags;
  69. CBasedTSetMemberPtr _ptsm;
  70. CBasedUpdatePtr _pudNext, _pudPrev;
  71. };
  72. //+--------------------------------------------------------------
  73. //
  74. // Member: CUpdate::GetCurrentName, public
  75. //
  76. // Synopsis: Returns the current name
  77. // Returns NULL for a zero length name
  78. //
  79. // History: 15-Jan-92 DrewB Created
  80. //
  81. //---------------------------------------------------------------
  82. inline CDfName *CUpdate::GetCurrentName(void)
  83. {
  84. return &_dfnCurrent;
  85. }
  86. //+--------------------------------------------------------------
  87. //
  88. // Member: CUpdate::GetOriginalName, public
  89. //
  90. // Synopsis: Returns the original name
  91. //
  92. // History: 15-Jan-92 DrewB Created
  93. //
  94. //---------------------------------------------------------------
  95. inline CDfName *CUpdate::GetOriginalName(void)
  96. {
  97. return &_dfnOriginal;
  98. }
  99. //+--------------------------------------------------------------
  100. //
  101. // Member: CUpdate::GetLUID, public
  102. //
  103. // Synopsis: Returns _dl
  104. //
  105. // History: 15-Jan-92 DrewB Created
  106. //
  107. //---------------------------------------------------------------
  108. inline DFLUID CUpdate::GetLUID(void) const
  109. {
  110. return _dl;
  111. }
  112. //+--------------------------------------------------------------
  113. //
  114. // Member: CUpdate::GetFlags, public
  115. //
  116. // Synopsis: Returns _dwFlags
  117. //
  118. // History: 15-Jan-92 DrewB Created
  119. //
  120. //---------------------------------------------------------------
  121. inline DWORD CUpdate::GetFlags(void) const
  122. {
  123. return _dwFlags;
  124. }
  125. //+--------------------------------------------------------------
  126. //
  127. // Member: CUpdate::GetXSM, public
  128. //
  129. // Synopsis: Returns the XSM
  130. //
  131. // History: 15-Jan-92 DrewB Created
  132. //
  133. //---------------------------------------------------------------
  134. inline PTSetMember *CUpdate::GetXSM(void) const
  135. {
  136. return BP_TO_P(PTSetMember *, _ptsm);
  137. }
  138. //+--------------------------------------------------------------
  139. //
  140. // Member: CUpdate::GetNext, public
  141. //
  142. // Synopsis: Returns _pudNext
  143. //
  144. // History: 15-Jan-92 DrewB Created
  145. //
  146. //---------------------------------------------------------------
  147. inline CUpdate *CUpdate::GetNext(void) const
  148. {
  149. return BP_TO_P(CUpdate *, _pudNext);
  150. }
  151. //+--------------------------------------------------------------
  152. //
  153. // Member: CUpdate::GetPrev, public
  154. //
  155. // Synopsis: Returns _pudPrev
  156. //
  157. // History: 15-Jan-92 DrewB Created
  158. //
  159. //---------------------------------------------------------------
  160. inline CUpdate *CUpdate::GetPrev(void) const
  161. {
  162. return BP_TO_P(CUpdate *, _pudPrev);
  163. }
  164. //+--------------------------------------------------------------
  165. //
  166. // Member: CUpdate::IsDelete, public
  167. //
  168. // Synopsis: Returns whether this is a delete entry or not
  169. //
  170. // History: 15-Jan-92 DrewB Created
  171. //
  172. //---------------------------------------------------------------
  173. inline BOOL CUpdate::IsDelete(void) const
  174. {
  175. return _dfnCurrent.GetLength() == 0;
  176. }
  177. //+--------------------------------------------------------------
  178. //
  179. // Member: CUpdate::IsRename, public
  180. //
  181. // Synopsis: Returns whether this is a rename or not
  182. //
  183. // History: 15-Jan-92 DrewB Created
  184. //
  185. //---------------------------------------------------------------
  186. inline BOOL CUpdate::IsRename(void) const
  187. {
  188. return _dfnCurrent.GetLength() != 0 && _dfnOriginal.GetLength() != 0;
  189. }
  190. //+--------------------------------------------------------------
  191. //
  192. // Member: CUpdate::IsCreate, public
  193. //
  194. // Synopsis: Returns whether this is a create or not
  195. //
  196. // History: 15-Jan-92 DrewB Created
  197. //
  198. //---------------------------------------------------------------
  199. inline BOOL CUpdate::IsCreate(void) const
  200. {
  201. return _dfnOriginal.GetLength() == 0;
  202. }
  203. //+--------------------------------------------------------------
  204. //
  205. // Member: CUpdate::SetCurrentName, public
  206. //
  207. // Synopsis: Sets the current name
  208. //
  209. // History: 15-Jan-92 DrewB Created
  210. //
  211. //---------------------------------------------------------------
  212. inline void CUpdate::SetCurrentName(CDfName const *pdfn)
  213. {
  214. if (pdfn)
  215. _dfnCurrent = *pdfn;
  216. else
  217. _dfnCurrent.Set((WORD)0, (BYTE *)NULL);
  218. }
  219. //+--------------------------------------------------------------
  220. //
  221. // Member: CUpdate::SetOriginalName, public
  222. //
  223. // Synopsis: Sets the original name
  224. //
  225. // History: 15-Jan-92 DrewB Created
  226. //
  227. //---------------------------------------------------------------
  228. inline void CUpdate::SetOriginalName(CDfName const *pdfn)
  229. {
  230. if (pdfn)
  231. _dfnOriginal = *pdfn;
  232. else
  233. _dfnOriginal.Set((WORD)0, (BYTE *)NULL);
  234. }
  235. //+--------------------------------------------------------------
  236. //
  237. // Member: CUpdate::SetLUID, public
  238. //
  239. // Synopsis: Assigns _dl
  240. //
  241. // History: 15-Jan-92 DrewB Created
  242. //
  243. //---------------------------------------------------------------
  244. inline void CUpdate::SetLUID(DFLUID dl)
  245. {
  246. _dl = dl;
  247. }
  248. //+--------------------------------------------------------------
  249. //
  250. // Member: CUpdate::SetFlags, public
  251. //
  252. // Synopsis: Assigns _dwFlags
  253. //
  254. // History: 15-Jan-92 DrewB Created
  255. //
  256. //---------------------------------------------------------------
  257. inline void CUpdate::SetFlags(DWORD dwFlags)
  258. {
  259. _dwFlags = dwFlags;
  260. }
  261. //+--------------------------------------------------------------
  262. //
  263. // Member: CUpdate::SetXSM, public
  264. //
  265. // Synopsis: Sets the XSM
  266. //
  267. // History: 15-Jan-92 DrewB Created
  268. //
  269. //---------------------------------------------------------------
  270. inline void CUpdate::SetXSM(PTSetMember *ptsm)
  271. {
  272. if (_ptsm)
  273. _ptsm->Release();
  274. _ptsm = P_TO_BP(CBasedTSetMemberPtr, ptsm);
  275. if (_ptsm)
  276. _ptsm->AddRef();
  277. }
  278. //+--------------------------------------------------------------
  279. //
  280. // Member: CUpdate::SetNext, public
  281. //
  282. // Synopsis: Assigns _pudNext
  283. //
  284. // History: 15-Jan-92 DrewB Created
  285. //
  286. //---------------------------------------------------------------
  287. inline void CUpdate::SetNext(CUpdate *pud)
  288. {
  289. _pudNext = P_TO_BP(CBasedUpdatePtr, pud);
  290. }
  291. //+--------------------------------------------------------------
  292. //
  293. // Member: CUpdate::SetPrev, public
  294. //
  295. // Synopsis: Assigns _pudPrev
  296. //
  297. // History: 15-Jan-92 DrewB Created
  298. //
  299. //---------------------------------------------------------------
  300. inline void CUpdate::SetPrev(CUpdate *pud)
  301. {
  302. _pudPrev = P_TO_BP(CBasedUpdatePtr, pud);
  303. }
  304. // Return codes for IsEntry
  305. enum UlIsEntry
  306. {
  307. UIE_CURRENT, UIE_ORIGINAL, UIE_NOTFOUND
  308. };
  309. //+--------------------------------------------------------------
  310. //
  311. // Class: CUpdateList (ul)
  312. //
  313. // Purpose: Maintains a list of update elements
  314. //
  315. // Interface: See below
  316. //
  317. // History: 22-Jun-92 DrewB Created
  318. //
  319. //---------------------------------------------------------------
  320. class CUpdateList
  321. {
  322. public:
  323. CUpdateList(void);
  324. ~CUpdateList(void);
  325. CUpdate *Add(IMalloc * const pMalloc,
  326. CDfName const *pdfnCurrent,
  327. CDfName const *pdfnOriginal,
  328. DFLUID dlLUID,
  329. DWORD dwFlags,
  330. PTSetMember *ptsm);
  331. void Append(CUpdate *pud);
  332. void Remove(CUpdate *pud);
  333. inline void Delete(CUpdate *pud);
  334. void Empty(void);
  335. inline void Unlink(void);
  336. inline CUpdate *GetHead(void) const;
  337. inline CUpdate *GetTail(void) const;
  338. UlIsEntry IsEntry(CDfName const *pdfn, CUpdate **ppud);
  339. static BOOL Exists(CUpdate *pud, CDfName const **ppdfn, BOOL fRename);
  340. static CUpdate *FindBase(CUpdate *pud, CDfName const **ppdfn);
  341. private:
  342. CBasedUpdatePtr _pudHead, _pudTail;
  343. };
  344. //+--------------------------------------------------------------
  345. //
  346. // Member: CUpdateList::CUpdateList, public
  347. //
  348. // Synopsis: ctor
  349. //
  350. // History: 22-Jun-92 DrewB Created
  351. //
  352. //---------------------------------------------------------------
  353. inline CUpdateList::CUpdateList(void)
  354. {
  355. _pudHead = _pudTail = NULL;
  356. }
  357. //+--------------------------------------------------------------
  358. //
  359. // Member: CUpdateList::~CUpdateList, public
  360. //
  361. // Synopsis: dtor
  362. //
  363. // History: 22-Jun-92 DrewB Created
  364. //
  365. //---------------------------------------------------------------
  366. inline CUpdateList::~CUpdateList(void)
  367. {
  368. olAssert(_pudHead == NULL && _pudTail == NULL);
  369. }
  370. //+--------------------------------------------------------------
  371. //
  372. // Member: CUpdateList::GetHead, public
  373. //
  374. // Synopsis: Returns _pudHead
  375. //
  376. // History: 22-Jun-92 DrewB Created
  377. //
  378. //---------------------------------------------------------------
  379. CUpdate *CUpdateList::GetHead(void) const
  380. {
  381. return BP_TO_P(CUpdate *, _pudHead);
  382. }
  383. //+--------------------------------------------------------------
  384. //
  385. // Member: CUpdateList::GetTail, public
  386. //
  387. // Synopsis: Returns list tail
  388. //
  389. // History: 22-Jun-92 DrewB Created
  390. //
  391. //---------------------------------------------------------------
  392. CUpdate *CUpdateList::GetTail(void) const
  393. {
  394. return BP_TO_P(CUpdate *, _pudTail);
  395. }
  396. //+--------------------------------------------------------------
  397. //
  398. // Member: CUpdateList::Unlink, public
  399. //
  400. // Synopsis: Unlinks the list
  401. //
  402. // History: 04-Aug-92 DrewB Created
  403. //
  404. // Notes: Used for ownership transfer
  405. //
  406. //---------------------------------------------------------------
  407. inline void CUpdateList::Unlink(void)
  408. {
  409. _pudHead = _pudTail = NULL;
  410. }
  411. //+--------------------------------------------------------------
  412. //
  413. // Member: CUpdateList::Delete, public
  414. //
  415. // Synopsis: Removes the given entry from the list and frees it
  416. //
  417. // Arguments: [pud] - Element to remove
  418. //
  419. // History: 20-Jan-92 DrewB Created
  420. //
  421. //---------------------------------------------------------------
  422. inline void CUpdateList::Delete(CUpdate *pud)
  423. {
  424. Remove(pud);
  425. delete pud;
  426. }
  427. #endif