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.

262 lines
5.1 KiB

  1. #include "inspch.h"
  2. #include "util2.h"
  3. #include "inseng.h"
  4. #include "ciffile.h"
  5. CCifEntryEnum::CCifEntryEnum(UINT dwFilter, UINT dwParentType, LPSTR pszParentID)
  6. {
  7. _cRef = 0;
  8. _uIndex = 0;
  9. _uFilter = dwFilter;
  10. if(_uFilter == 0)
  11. _uFilter = PLATFORM_ALL;
  12. _uParentType = dwParentType;
  13. if(_uParentType != PARENTTYPE_CIF)
  14. lstrcpyn(_szParentID, pszParentID, MAX_ID_LENGTH);
  15. }
  16. CCifEntryEnum::~CCifEntryEnum()
  17. {
  18. }
  19. CCifComponentEnum::CCifComponentEnum(CCifComponent **rpcomp, UINT dwFilter, UINT dwParentType, LPSTR pszParentID)
  20. : CCifEntryEnum(dwFilter, dwParentType, pszParentID)
  21. {
  22. _rpComp = rpcomp;
  23. }
  24. CCifComponentEnum::~CCifComponentEnum()
  25. {
  26. }
  27. //************ IUnknown implementation ***************
  28. STDMETHODIMP_(ULONG) CCifComponentEnum::AddRef()
  29. {
  30. return(_cRef++);
  31. }
  32. STDMETHODIMP_(ULONG) CCifComponentEnum::Release()
  33. {
  34. ULONG temp = --_cRef;
  35. if(temp == 0)
  36. delete this;
  37. return temp;
  38. }
  39. STDMETHODIMP CCifComponentEnum::QueryInterface(REFIID riid, void **ppv)
  40. {
  41. *ppv = NULL;
  42. if(riid == IID_IUnknown)
  43. *ppv = (IEnumCifComponents *)this;
  44. if(*ppv == NULL)
  45. return E_NOINTERFACE;
  46. AddRef();
  47. return NOERROR;
  48. }
  49. STDMETHODIMP CCifComponentEnum::Next(ICifComponent **pp)
  50. {
  51. *pp = NULL;
  52. HRESULT hr = E_FAIL;
  53. CCifComponent *pcomp;
  54. for(pcomp = _rpComp[_uIndex]; pcomp != 0; pcomp = _rpComp[++_uIndex])
  55. {
  56. // check filters
  57. if(_rpComp[_uIndex]->GetPlatform() & _uFilter)
  58. {
  59. char szID[MAX_ID_LENGTH];
  60. BOOL bParentOK = FALSE;
  61. // platform is ok
  62. if(_uParentType == PARENTTYPE_GROUP)
  63. {
  64. pcomp->GetGroup(szID, sizeof(szID));
  65. if(lstrcmpi(_szParentID, szID) == 0)
  66. bParentOK = TRUE;
  67. }
  68. else if(_uParentType == PARENTTYPE_MODE)
  69. {
  70. // look though the modes for one that matches
  71. for(int i = 0; SUCCEEDED(pcomp->GetMode(i, szID, sizeof(szID))); i++)
  72. {
  73. if(lstrcmpi(szID, _szParentID) == 0)
  74. bParentOK = TRUE;
  75. }
  76. }
  77. else
  78. bParentOK = TRUE;
  79. if(bParentOK)
  80. {
  81. hr = NOERROR;
  82. *pp = (ICifComponent *) pcomp;
  83. _uIndex++; // increment _uIndex so next call to Next keeps moving
  84. break;
  85. }
  86. }
  87. }
  88. return hr;
  89. }
  90. STDMETHODIMP CCifComponentEnum::Reset()
  91. {
  92. _uIndex = 0;
  93. return NOERROR;
  94. }
  95. //***************** CCifGroupEnum *****************************
  96. CCifGroupEnum::CCifGroupEnum(CCifGroup **rpgrp, UINT dwFilter)
  97. : CCifEntryEnum(dwFilter, PARENTTYPE_CIF, NULL)
  98. {
  99. _rpGroup = rpgrp;
  100. }
  101. CCifGroupEnum::~CCifGroupEnum()
  102. {
  103. }
  104. //************ IUnknown implementation ***************
  105. STDMETHODIMP_(ULONG) CCifGroupEnum::AddRef()
  106. {
  107. return(_cRef++);
  108. }
  109. STDMETHODIMP_(ULONG) CCifGroupEnum::Release()
  110. {
  111. ULONG temp = --_cRef;
  112. if(temp == 0)
  113. delete this;
  114. return temp;
  115. }
  116. STDMETHODIMP CCifGroupEnum::QueryInterface(REFIID riid, void **ppv)
  117. {
  118. *ppv = NULL;
  119. if(riid == IID_IUnknown)
  120. *ppv = (IEnumCifGroups *)this;
  121. if(*ppv == NULL)
  122. return E_NOINTERFACE;
  123. AddRef();
  124. return NOERROR;
  125. }
  126. STDMETHODIMP CCifGroupEnum::Next(ICifGroup **pp)
  127. {
  128. HRESULT hr = E_FAIL;
  129. CCifGroup *pgrp;
  130. *pp = NULL;
  131. for(pgrp = _rpGroup[_uIndex]; pgrp != 0; pgrp = _rpGroup[++_uIndex])
  132. {
  133. hr = NOERROR;
  134. *pp = (ICifGroup *) pgrp;
  135. _uIndex++; // increment _uIndex so next call to Next keeps moving
  136. break;
  137. }
  138. return hr;
  139. }
  140. STDMETHODIMP CCifGroupEnum::Reset()
  141. {
  142. _uIndex = 0;
  143. return NOERROR;
  144. }
  145. //***************** CCifModeEnum *****************************
  146. CCifModeEnum::CCifModeEnum(CCifMode **rpmode, UINT dwFilter)
  147. : CCifEntryEnum(dwFilter, PARENTTYPE_CIF, NULL)
  148. {
  149. _rpMode = rpmode;
  150. }
  151. CCifModeEnum::~CCifModeEnum()
  152. {
  153. }
  154. //************ IUnknown implementation ***************
  155. STDMETHODIMP_(ULONG) CCifModeEnum::AddRef()
  156. {
  157. return(_cRef++);
  158. }
  159. STDMETHODIMP_(ULONG) CCifModeEnum::Release()
  160. {
  161. ULONG temp = --_cRef;
  162. if(temp == 0)
  163. delete this;
  164. return temp;
  165. }
  166. STDMETHODIMP CCifModeEnum::QueryInterface(REFIID riid, void **ppv)
  167. {
  168. *ppv = NULL;
  169. if(riid == IID_IUnknown)
  170. *ppv = (IEnumCifModes *)this;
  171. if(*ppv == NULL)
  172. return E_NOINTERFACE;
  173. AddRef();
  174. return NOERROR;
  175. }
  176. STDMETHODIMP CCifModeEnum::Next(ICifMode **pp)
  177. {
  178. HRESULT hr = E_FAIL;
  179. CCifMode *pmode;
  180. *pp = NULL;
  181. for(pmode = _rpMode[_uIndex]; pmode != 0; pmode = _rpMode[++_uIndex])
  182. {
  183. hr = NOERROR;
  184. *pp = (ICifMode *) pmode;
  185. _uIndex++; // increment _uIndex so next call to Next keeps moving
  186. break;
  187. }
  188. return hr;
  189. }
  190. STDMETHODIMP CCifModeEnum::Reset()
  191. {
  192. _uIndex = 0;
  193. return NOERROR;
  194. }