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.

171 lines
4.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: peiter.cxx
  7. //
  8. // Contents: Implementation of PExposedIterator
  9. //
  10. // History: 18-Jan-93 DrewB Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <exphead.cxx>
  14. #pragma hdrstop
  15. #include <peiter.hxx>
  16. #include <expparam.hxx>
  17. //+---------------------------------------------------------------------------
  18. //
  19. // Member: PExposedIterator::hSkip, public
  20. //
  21. // Synopsis: Enumerator skip helper function
  22. //
  23. // History: 18-Jan-93 DrewB Created
  24. //
  25. //----------------------------------------------------------------------------
  26. #ifdef CODESEGMENTS
  27. #pragma code_seg(SEG_PExposedIterator_hSkip)
  28. #endif
  29. SCODE PExposedIterator::hSkip(ULONG celt, BOOL fProps)
  30. {
  31. SCODE sc;
  32. #ifndef REF
  33. SAFE_SEM;
  34. SAFE_ACCESS;
  35. #endif //!REF
  36. SIterBuffer ib;
  37. olDebugOut((DEB_ITRACE, "In PExposedIterator::hSkip:%p(%lu, %d)\n",
  38. this, celt, fProps));
  39. #ifndef REF
  40. olChk(TakeSafeSem());
  41. olChk(_ppdf->CheckReverted());
  42. SafeReadAccess();
  43. #endif //!REF
  44. for (; celt>0; celt--)
  45. {
  46. sc = _ppdf->FindGreaterEntry(&_dfnKey, &ib, NULL, fProps);
  47. if (FAILED(sc))
  48. {
  49. if (sc == STG_E_NOMOREFILES)
  50. sc = S_FALSE;
  51. break;
  52. }
  53. _dfnKey.Set(&ib.dfnName);
  54. }
  55. olDebugOut((DEB_ITRACE, "Out PExposedIterator::hSkip\n"));
  56. EH_Err:
  57. return sc;
  58. }
  59. //+---------------------------------------------------------------------------
  60. //
  61. // Member: PExposedIterator::hRelease, public
  62. //
  63. // Synopsis: Release helper
  64. //
  65. // History: 18-Jan-93 DrewB Created
  66. //
  67. //----------------------------------------------------------------------------
  68. #ifdef CODESEGMENTS
  69. #pragma code_seg(SEG_PExposedIterator_hRelease)
  70. #endif
  71. LONG PExposedIterator::hRelease(void)
  72. {
  73. LONG lRet;
  74. olDebugOut((DEB_ITRACE, "In PExposedIterator::hRelease:%p()\n", this));
  75. olAssert(_cReferences > 0);
  76. lRet = InterlockedDecrement(&_cReferences);
  77. if (lRet < 0)
  78. {
  79. lRet = 0;
  80. }
  81. olDebugOut((DEB_ITRACE, "Out PExposedIterator::hRelease => %lu\n", lRet));
  82. return lRet;
  83. }
  84. //+---------------------------------------------------------------------------
  85. //
  86. // Member: PExposedIterator::hQueryInterface, public
  87. //
  88. // Synopsis: QueryInterface helper
  89. //
  90. // History: 18-Jan-93 DrewB Created
  91. //
  92. //----------------------------------------------------------------------------
  93. #ifdef CODESEGMENTS
  94. #pragma code_seg(SEG_PExposedIterator_hQueryInterface)
  95. #endif
  96. SCODE PExposedIterator::hQueryInterface(REFIID iid,
  97. REFIID riidSelf,
  98. IUnknown *punkSelf,
  99. void **ppv)
  100. {
  101. SCODE sc;
  102. olDebugOut((DEB_ITRACE, "In PExposedIterator::hQueryInterface:%p("
  103. "riid, riidSelf, %p, %p)\n", this, punkSelf, ppv));
  104. OL_VALIDATE(QueryInterface(iid, ppv));
  105. #ifdef MULTIHEAP
  106. CSafeMultiHeap smh(_ppc);
  107. #endif
  108. olChk(_ppdf->CheckReverted());
  109. if (IsEqualIID(iid, riidSelf) || IsEqualIID(iid, IID_IUnknown))
  110. {
  111. *ppv = punkSelf;
  112. hAddRef();
  113. sc = S_OK;
  114. }
  115. else
  116. {
  117. sc = E_NOINTERFACE;
  118. }
  119. olDebugOut((DEB_ITRACE, "Out PExposedIterator::hQueryInterface\n"));
  120. EH_Err:
  121. return sc;
  122. }
  123. //+---------------------------------------------------------------------------
  124. //
  125. // Member: PExposedIterator::hReset, public
  126. //
  127. // Synopsis: Reset help
  128. //
  129. // History: 18-Jan-93 DrewB Created
  130. //
  131. //----------------------------------------------------------------------------
  132. SCODE PExposedIterator::hReset(void)
  133. {
  134. SCODE sc;
  135. SAFE_SEM;
  136. SAFE_ACCESS;
  137. olDebugOut((DEB_ITRACE, "In PExposedIterator::hReset:%p()\n", this));
  138. olChk(TakeSafeSem());
  139. SafeReadAccess();
  140. _dfnKey.Set((WORD)0, (BYTE *)NULL);
  141. sc = _ppdf->CheckReverted();
  142. olDebugOut((DEB_ITRACE, "Out PExposedIterator::hReset\n"));
  143. EH_Err:
  144. return sc;
  145. }