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.

1357 lines
25 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1997 **/
  4. /**********************************************************************/
  5. /*
  6. info.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "infoi.h"
  11. /*---------------------------------------------------------------------------
  12. Class: EnumRtrMgrCB
  13. Definition and implementation
  14. ---------------------------------------------------------------------------*/
  15. class EnumRtrMgrCB
  16. : public IEnumRtrMgrCB
  17. {
  18. public:
  19. DeclareIUnknownMembers(IMPL)
  20. DeclareIEnumRtrMgrCBMembers(IMPL)
  21. EnumRtrMgrCB() : m_cRef(1)
  22. {
  23. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrCB);
  24. }
  25. #ifdef DEBUG
  26. ~EnumRtrMgrCB()
  27. {
  28. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrCB);
  29. }
  30. #endif
  31. HRESULT Init(SRtrMgrCBList *pRmCBList);
  32. protected:
  33. LONG m_cRef;
  34. POSITION m_pos;
  35. SRtrMgrCBList * m_pRmCBList;
  36. };
  37. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrCB);
  38. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrCB, IEnumRtrMgrCB)
  39. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrCB)
  40. HRESULT EnumRtrMgrCB::Init(SRtrMgrCBList *pRmCBList)
  41. {
  42. m_pRmCBList = pRmCBList;
  43. Reset();
  44. return hrOK;
  45. }
  46. HRESULT EnumRtrMgrCB::Next(ULONG uNum, RtrMgrCB *pRmCB, ULONG *pNumReturned)
  47. {
  48. Assert(uNum == 1);
  49. Assert(pRmCB);
  50. HRESULT hr = hrOK;
  51. SRtrMgrCB *pSRmCB;
  52. COM_PROTECT_TRY
  53. {
  54. if (m_pos)
  55. {
  56. pSRmCB = m_pRmCBList->GetNext(m_pos);
  57. Assert(pSRmCB);
  58. pSRmCB->SaveTo(pRmCB);
  59. if (pNumReturned)
  60. *pNumReturned = 1;
  61. hr = hrOK;
  62. }
  63. else
  64. {
  65. if (pNumReturned)
  66. *pNumReturned = 0;
  67. hr = hrFalse;
  68. }
  69. }
  70. COM_PROTECT_CATCH;
  71. return hr;
  72. }
  73. HRESULT EnumRtrMgrCB::Skip(ULONG uNum)
  74. {
  75. Assert(uNum == 1);
  76. HRESULT hr = hrOK;
  77. COM_PROTECT_TRY
  78. {
  79. if (m_pos)
  80. {
  81. m_pRmCBList->GetNext(m_pos);
  82. }
  83. }
  84. COM_PROTECT_CATCH;
  85. return hr;
  86. }
  87. HRESULT EnumRtrMgrCB::Reset()
  88. {
  89. HRESULT hr = hrOK;
  90. COM_PROTECT_TRY
  91. {
  92. m_pos = m_pRmCBList->GetHeadPosition();
  93. }
  94. COM_PROTECT_CATCH;
  95. return hr;
  96. }
  97. HRESULT EnumRtrMgrCB::Clone(IEnumRtrMgrCB **ppBlockEnum)
  98. {
  99. return E_NOTIMPL;
  100. }
  101. /*---------------------------------------------------------------------------
  102. Class: EnumRtrMgrProtocolCB
  103. ---------------------------------------------------------------------------*/
  104. class EnumRtrMgrProtocolCB
  105. : public IEnumRtrMgrProtocolCB
  106. {
  107. public:
  108. DeclareIUnknownMembers(IMPL)
  109. DeclareIEnumRtrMgrProtocolCBMembers(IMPL)
  110. EnumRtrMgrProtocolCB() : m_cRef(1)
  111. {
  112. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolCB);
  113. }
  114. #ifdef DEBUG
  115. ~EnumRtrMgrProtocolCB()
  116. {
  117. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolCB);
  118. }
  119. #endif
  120. HRESULT Init(SRtrMgrProtocolCBList *pRmProtCBList);
  121. protected:
  122. LONG m_cRef;
  123. POSITION m_pos;
  124. SRtrMgrProtocolCBList * m_pRmProtCBList;
  125. };
  126. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrProtocolCB);
  127. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrProtocolCB, IEnumRtrMgrProtocolCB)
  128. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrProtocolCB)
  129. HRESULT EnumRtrMgrProtocolCB::Init(SRtrMgrProtocolCBList *pRmProtCBList)
  130. {
  131. m_pRmProtCBList = pRmProtCBList;
  132. Reset();
  133. return hrOK;
  134. }
  135. HRESULT EnumRtrMgrProtocolCB::Next(ULONG uNum, RtrMgrProtocolCB *pRmProtCB, ULONG *pNumReturned)
  136. {
  137. Assert(uNum == 1);
  138. Assert(pRmProtCB);
  139. HRESULT hr = hrOK;
  140. SRtrMgrProtocolCB *pSRmProtCB;
  141. COM_PROTECT_TRY
  142. {
  143. if (m_pos)
  144. {
  145. pSRmProtCB = m_pRmProtCBList->GetNext(m_pos);
  146. Assert(pSRmProtCB);
  147. pSRmProtCB->SaveTo(pRmProtCB);
  148. if (pNumReturned)
  149. *pNumReturned = 1;
  150. hr = hrOK;
  151. }
  152. else
  153. {
  154. if (pNumReturned)
  155. *pNumReturned = 0;
  156. hr = hrFalse;
  157. }
  158. }
  159. COM_PROTECT_CATCH;
  160. return hr;
  161. }
  162. HRESULT EnumRtrMgrProtocolCB::Skip(ULONG uNum)
  163. {
  164. Assert(uNum == 1);
  165. HRESULT hr = hrOK;
  166. COM_PROTECT_TRY
  167. {
  168. if (m_pos)
  169. {
  170. m_pRmProtCBList->GetNext(m_pos);
  171. }
  172. }
  173. COM_PROTECT_CATCH;
  174. return hr;
  175. }
  176. HRESULT EnumRtrMgrProtocolCB::Reset()
  177. {
  178. HRESULT hr = hrOK;
  179. COM_PROTECT_TRY
  180. {
  181. m_pos = m_pRmProtCBList->GetHeadPosition();
  182. }
  183. COM_PROTECT_CATCH;
  184. return hr;
  185. }
  186. HRESULT EnumRtrMgrProtocolCB::Clone(IEnumRtrMgrProtocolCB **ppBlockEnum)
  187. {
  188. return E_NOTIMPL;
  189. }
  190. /*---------------------------------------------------------------------------
  191. Class: EnumInterfaceCB
  192. ---------------------------------------------------------------------------*/
  193. class EnumInterfaceCB
  194. : public IEnumInterfaceCB
  195. {
  196. public:
  197. DeclareIUnknownMembers(IMPL)
  198. DeclareIEnumInterfaceCBMembers(IMPL)
  199. EnumInterfaceCB() : m_cRef(1)
  200. {
  201. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumInterfaceCB);
  202. }
  203. #ifdef DEBUG
  204. ~EnumInterfaceCB()
  205. {
  206. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumInterfaceCB);
  207. }
  208. #endif
  209. HRESULT Init(SInterfaceCBList *pIfCBList);
  210. protected:
  211. LONG m_cRef;
  212. POSITION m_pos;
  213. SInterfaceCBList * m_pIfCBList;
  214. };
  215. IMPLEMENT_ADDREF_RELEASE(EnumInterfaceCB);
  216. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumInterfaceCB, IEnumInterfaceCB)
  217. DEBUG_DECLARE_INSTANCE_COUNTER(EnumInterfaceCB)
  218. HRESULT EnumInterfaceCB::Init(SInterfaceCBList *pIfCBList)
  219. {
  220. m_pIfCBList = pIfCBList;
  221. Reset();
  222. return hrOK;
  223. }
  224. HRESULT EnumInterfaceCB::Next(ULONG uNum, InterfaceCB *pIfCB, ULONG *pNumReturned)
  225. {
  226. Assert(uNum == 1);
  227. Assert(pIfCB);
  228. HRESULT hr = hrOK;
  229. SInterfaceCB *pSIfCB;
  230. COM_PROTECT_TRY
  231. {
  232. if (m_pos)
  233. {
  234. pSIfCB = m_pIfCBList->GetNext(m_pos);
  235. Assert(pSIfCB);
  236. pSIfCB->SaveTo(pIfCB);
  237. if (pNumReturned)
  238. *pNumReturned = 1;
  239. hr = hrOK;
  240. }
  241. else
  242. {
  243. if (pNumReturned)
  244. *pNumReturned = 0;
  245. hr = hrFalse;
  246. }
  247. }
  248. COM_PROTECT_CATCH;
  249. return hr;
  250. }
  251. HRESULT EnumInterfaceCB::Skip(ULONG uNum)
  252. {
  253. Assert(uNum == 1);
  254. HRESULT hr = hrOK;
  255. COM_PROTECT_TRY
  256. {
  257. if (m_pos)
  258. {
  259. m_pIfCBList->GetNext(m_pos);
  260. }
  261. }
  262. COM_PROTECT_CATCH;
  263. return hr;
  264. }
  265. HRESULT EnumInterfaceCB::Reset()
  266. {
  267. HRESULT hr = hrOK;
  268. COM_PROTECT_TRY
  269. {
  270. m_pos = m_pIfCBList->GetHeadPosition();
  271. }
  272. COM_PROTECT_CATCH;
  273. return hr;
  274. }
  275. HRESULT EnumInterfaceCB::Clone(IEnumInterfaceCB **ppBlockEnum)
  276. {
  277. return E_NOTIMPL;
  278. }
  279. /*---------------------------------------------------------------------------
  280. Class: EnumRtrMgrInterfaceCB
  281. ---------------------------------------------------------------------------*/
  282. class EnumRtrMgrInterfaceCB
  283. : public IEnumRtrMgrInterfaceCB
  284. {
  285. public:
  286. DeclareIUnknownMembers(IMPL)
  287. DeclareIEnumRtrMgrInterfaceCBMembers(IMPL)
  288. EnumRtrMgrInterfaceCB() : m_cRef(1)
  289. {
  290. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrInterfaceCB);
  291. }
  292. #ifdef DEBUG
  293. ~EnumRtrMgrInterfaceCB()
  294. {
  295. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrInterfaceCB);
  296. }
  297. #endif
  298. HRESULT Init(SRtrMgrInterfaceCBList *pRmIfCBList);
  299. protected:
  300. LONG m_cRef;
  301. POSITION m_pos;
  302. SRtrMgrInterfaceCBList * m_pRmIfCBList;
  303. };
  304. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrInterfaceCB);
  305. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrInterfaceCB, IEnumRtrMgrInterfaceCB)
  306. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrInterfaceCB)
  307. HRESULT EnumRtrMgrInterfaceCB::Init(SRtrMgrInterfaceCBList *pRmIfCBList)
  308. {
  309. m_pRmIfCBList = pRmIfCBList;
  310. Reset();
  311. return hrOK;
  312. }
  313. HRESULT EnumRtrMgrInterfaceCB::Next(ULONG uNum, RtrMgrInterfaceCB *pRmIfCB, ULONG *pNumReturned)
  314. {
  315. Assert(uNum == 1);
  316. Assert(pRmIfCB);
  317. HRESULT hr = hrOK;
  318. SRtrMgrInterfaceCB *pSRmIfCB;
  319. COM_PROTECT_TRY
  320. {
  321. if (m_pos)
  322. {
  323. pSRmIfCB = m_pRmIfCBList->GetNext(m_pos);
  324. Assert(pSRmIfCB);
  325. pSRmIfCB->SaveTo(pRmIfCB);
  326. if (pNumReturned)
  327. *pNumReturned = 1;
  328. hr = hrOK;
  329. }
  330. else
  331. {
  332. if (pNumReturned)
  333. *pNumReturned = 0;
  334. hr = hrFalse;
  335. }
  336. }
  337. COM_PROTECT_CATCH;
  338. return hr;
  339. }
  340. HRESULT EnumRtrMgrInterfaceCB::Skip(ULONG uNum)
  341. {
  342. Assert(uNum == 1);
  343. HRESULT hr = hrOK;
  344. COM_PROTECT_TRY
  345. {
  346. if (m_pos)
  347. {
  348. m_pRmIfCBList->GetNext(m_pos);
  349. }
  350. }
  351. COM_PROTECT_CATCH;
  352. return hr;
  353. }
  354. HRESULT EnumRtrMgrInterfaceCB::Reset()
  355. {
  356. HRESULT hr = hrOK;
  357. COM_PROTECT_TRY
  358. {
  359. m_pos = m_pRmIfCBList->GetHeadPosition();
  360. }
  361. COM_PROTECT_CATCH;
  362. return hr;
  363. }
  364. HRESULT EnumRtrMgrInterfaceCB::Clone(IEnumRtrMgrInterfaceCB **ppBlockEnum)
  365. {
  366. return E_NOTIMPL;
  367. }
  368. /*---------------------------------------------------------------------------
  369. Class: EnumRtrMgrInterfaceProtocolCB
  370. ---------------------------------------------------------------------------*/
  371. class EnumRtrMgrProtocolInterfaceCB
  372. : public IEnumRtrMgrProtocolInterfaceCB
  373. {
  374. public:
  375. DeclareIUnknownMembers(IMPL)
  376. DeclareIEnumRtrMgrProtocolInterfaceCBMembers(IMPL)
  377. EnumRtrMgrProtocolInterfaceCB() : m_cRef(1)
  378. {
  379. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceCB);
  380. }
  381. #ifdef DEBUG
  382. ~EnumRtrMgrProtocolInterfaceCB()
  383. {
  384. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceCB);
  385. }
  386. #endif
  387. HRESULT Init(SRtrMgrProtocolInterfaceCBList *pRmProtIfCBList);
  388. protected:
  389. LONG m_cRef;
  390. POSITION m_pos;
  391. SRtrMgrProtocolInterfaceCBList * m_pRmProtIfCBList;
  392. };
  393. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrProtocolInterfaceCB);
  394. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrProtocolInterfaceCB, IEnumRtrMgrProtocolInterfaceCB)
  395. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceCB)
  396. HRESULT EnumRtrMgrProtocolInterfaceCB::Init(SRtrMgrProtocolInterfaceCBList *pRmProtIfCBList)
  397. {
  398. m_pRmProtIfCBList = pRmProtIfCBList;
  399. Reset();
  400. return hrOK;
  401. }
  402. HRESULT EnumRtrMgrProtocolInterfaceCB::Next(ULONG uNum, RtrMgrProtocolInterfaceCB *pRmProtIfCB, ULONG *pNumReturned)
  403. {
  404. Assert(uNum == 1);
  405. Assert(pRmProtIfCB);
  406. HRESULT hr = hrOK;
  407. SRtrMgrProtocolInterfaceCB *pSRmProtIfCB;
  408. COM_PROTECT_TRY
  409. {
  410. if (m_pos)
  411. {
  412. pSRmProtIfCB = m_pRmProtIfCBList->GetNext(m_pos);
  413. Assert(pSRmProtIfCB);
  414. pSRmProtIfCB->SaveTo(pRmProtIfCB);
  415. if (pNumReturned)
  416. *pNumReturned = 1;
  417. hr = hrOK;
  418. }
  419. else
  420. {
  421. if (pNumReturned)
  422. *pNumReturned = 0;
  423. hr = hrFalse;
  424. }
  425. }
  426. COM_PROTECT_CATCH;
  427. return hr;
  428. }
  429. HRESULT EnumRtrMgrProtocolInterfaceCB::Skip(ULONG uNum)
  430. {
  431. Assert(uNum == 1);
  432. HRESULT hr = hrOK;
  433. COM_PROTECT_TRY
  434. {
  435. if (m_pos)
  436. {
  437. m_pRmProtIfCBList->GetNext(m_pos);
  438. }
  439. }
  440. COM_PROTECT_CATCH;
  441. return hr;
  442. }
  443. HRESULT EnumRtrMgrProtocolInterfaceCB::Reset()
  444. {
  445. HRESULT hr = hrOK;
  446. COM_PROTECT_TRY
  447. {
  448. m_pos = m_pRmProtIfCBList->GetHeadPosition();
  449. }
  450. COM_PROTECT_CATCH;
  451. return hr;
  452. }
  453. HRESULT EnumRtrMgrProtocolInterfaceCB::Clone(IEnumRtrMgrProtocolInterfaceCB **ppBlockEnum)
  454. {
  455. return E_NOTIMPL;
  456. }
  457. /*!--------------------------------------------------------------------------
  458. CreateEnumFromSRmCBList
  459. -
  460. Author: KennT
  461. ---------------------------------------------------------------------------*/
  462. HRESULT CreateEnumFromSRmCBList(SRtrMgrCBList *pRmCBList,
  463. IEnumRtrMgrCB **ppEnum)
  464. {
  465. Assert(pRmCBList);
  466. Assert(ppEnum);
  467. HRESULT hr = hrOK;
  468. EnumRtrMgrCB * pEnum;
  469. pEnum = new EnumRtrMgrCB;
  470. hr = pEnum->Init(pRmCBList);
  471. if (!FHrSucceeded(hr))
  472. {
  473. pEnum->Release();
  474. pEnum = NULL;
  475. }
  476. *ppEnum = pEnum;
  477. return hr;
  478. }
  479. /*!--------------------------------------------------------------------------
  480. CreateEnumFromSRmProtCBList
  481. -
  482. Author: KennT
  483. ---------------------------------------------------------------------------*/
  484. HRESULT CreateEnumFromSRmProtCBList(SRtrMgrProtocolCBList *pRmProtCBList,
  485. IEnumRtrMgrProtocolCB **ppEnum)
  486. {
  487. Assert(pRmProtCBList);
  488. Assert(ppEnum);
  489. HRESULT hr = hrOK;
  490. EnumRtrMgrProtocolCB * pEnum;
  491. pEnum = new EnumRtrMgrProtocolCB;
  492. hr = pEnum->Init(pRmProtCBList);
  493. if (!FHrSucceeded(hr))
  494. {
  495. pEnum->Release();
  496. pEnum = NULL;
  497. }
  498. *ppEnum = pEnum;
  499. return hr;
  500. }
  501. /*!--------------------------------------------------------------------------
  502. CreateEnumFromSIfCBList
  503. -
  504. Author: KennT
  505. ---------------------------------------------------------------------------*/
  506. HRESULT CreateEnumFromSIfCBList(SInterfaceCBList *pIfCBList,
  507. IEnumInterfaceCB **ppEnum)
  508. {
  509. Assert(pIfCBList);
  510. Assert(ppEnum);
  511. HRESULT hr = hrOK;
  512. EnumInterfaceCB * pEnum;
  513. pEnum = new EnumInterfaceCB;
  514. hr = pEnum->Init(pIfCBList);
  515. if (!FHrSucceeded(hr))
  516. {
  517. pEnum->Release();
  518. pEnum = NULL;
  519. }
  520. *ppEnum = pEnum;
  521. return hr;
  522. }
  523. /*!--------------------------------------------------------------------------
  524. CreateEnumFromSRmIfCBList
  525. -
  526. Author: KennT
  527. ---------------------------------------------------------------------------*/
  528. HRESULT CreateEnumFromSRmIfCBList(SRtrMgrInterfaceCBList *pRmIfCBList,
  529. IEnumRtrMgrInterfaceCB **ppEnum)
  530. {
  531. Assert(pRmIfCBList);
  532. Assert(ppEnum);
  533. HRESULT hr = hrOK;
  534. EnumRtrMgrInterfaceCB * pEnum;
  535. pEnum = new EnumRtrMgrInterfaceCB;
  536. hr = pEnum->Init(pRmIfCBList);
  537. if (!FHrSucceeded(hr))
  538. {
  539. pEnum->Release();
  540. pEnum = NULL;
  541. }
  542. *ppEnum = pEnum;
  543. return hr;
  544. }
  545. /*!--------------------------------------------------------------------------
  546. CreateEnumFromSRmProtIfCBList
  547. -
  548. Author: KennT
  549. ---------------------------------------------------------------------------*/
  550. HRESULT CreateEnumFromSRmProtIfCBList(SRtrMgrProtocolInterfaceCBList *pRmProtIfCBList,
  551. IEnumRtrMgrProtocolInterfaceCB **ppEnum)
  552. {
  553. Assert(pRmProtIfCBList);
  554. Assert(ppEnum);
  555. HRESULT hr = hrOK;
  556. EnumRtrMgrProtocolInterfaceCB * pEnum;
  557. pEnum = new EnumRtrMgrProtocolInterfaceCB;
  558. hr = pEnum->Init(pRmProtIfCBList);
  559. if (!FHrSucceeded(hr))
  560. {
  561. pEnum->Release();
  562. pEnum = NULL;
  563. }
  564. *ppEnum = pEnum;
  565. return hr;
  566. }
  567. /*---------------------------------------------------------------------------
  568. Class: EnumRtrMgrList
  569. Definition and implementation
  570. ---------------------------------------------------------------------------*/
  571. class EnumRtrMgrList
  572. : public IEnumRtrMgrInfo
  573. {
  574. public:
  575. DeclareIUnknownMembers(IMPL)
  576. DeclareIEnumRtrMgrInfoMembers(IMPL)
  577. EnumRtrMgrList() : m_cRef(1)
  578. {
  579. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrList);
  580. }
  581. #ifdef DEBUG
  582. ~EnumRtrMgrList()
  583. {
  584. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrList);
  585. }
  586. #endif
  587. HRESULT Init(RmDataList *pRmList);
  588. protected:
  589. LONG m_cRef;
  590. POSITION m_pos;
  591. RmDataList * m_pRmList;
  592. };
  593. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrList);
  594. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrList, IEnumRtrMgrInfo)
  595. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrList)
  596. HRESULT EnumRtrMgrList::Init(RmDataList *pRmList)
  597. {
  598. m_pRmList = pRmList;
  599. Reset();
  600. return hrOK;
  601. }
  602. HRESULT EnumRtrMgrList::Next(ULONG uNum, IRtrMgrInfo **ppRm, ULONG *pNumReturned)
  603. {
  604. Assert(uNum == 1);
  605. Assert(ppRm);
  606. HRESULT hr = hrOK;
  607. SRmData rmData;
  608. COM_PROTECT_TRY
  609. {
  610. if (m_pos)
  611. {
  612. rmData = m_pRmList->GetNext(m_pos);
  613. *ppRm = rmData.m_pRmInfo;
  614. (*ppRm)->AddRef();
  615. if (pNumReturned)
  616. *pNumReturned = 1;
  617. hr = hrOK;
  618. }
  619. else
  620. {
  621. if (pNumReturned)
  622. *pNumReturned = 0;
  623. hr = hrFalse;
  624. }
  625. }
  626. COM_PROTECT_CATCH;
  627. return hr;
  628. }
  629. HRESULT EnumRtrMgrList::Skip(ULONG uNum)
  630. {
  631. Assert(uNum == 1);
  632. HRESULT hr = hrOK;
  633. COM_PROTECT_TRY
  634. {
  635. if (m_pos)
  636. {
  637. m_pRmList->GetNext(m_pos);
  638. }
  639. }
  640. COM_PROTECT_CATCH;
  641. return hr;
  642. }
  643. HRESULT EnumRtrMgrList::Reset()
  644. {
  645. HRESULT hr = hrOK;
  646. COM_PROTECT_TRY
  647. {
  648. m_pos = m_pRmList->GetHeadPosition();
  649. }
  650. COM_PROTECT_CATCH;
  651. return hr;
  652. }
  653. HRESULT EnumRtrMgrList::Clone(IEnumRtrMgrInfo **ppBlockEnum)
  654. {
  655. return E_NOTIMPL;
  656. }
  657. /*---------------------------------------------------------------------------
  658. Class: EnumRtrMgrProtocolList
  659. Definition and implementation
  660. ---------------------------------------------------------------------------*/
  661. class EnumRtrMgrProtocolList
  662. : public IEnumRtrMgrProtocolInfo
  663. {
  664. public:
  665. DeclareIUnknownMembers(IMPL)
  666. DeclareIEnumRtrMgrProtocolInfoMembers(IMPL)
  667. EnumRtrMgrProtocolList() : m_cRef(1)
  668. {
  669. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolList);
  670. }
  671. #ifdef DEBUG
  672. ~EnumRtrMgrProtocolList()
  673. {
  674. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolList);
  675. }
  676. #endif
  677. HRESULT Init(PRtrMgrProtocolInfoList *pRmProtList);
  678. protected:
  679. LONG m_cRef;
  680. POSITION m_pos;
  681. PRtrMgrProtocolInfoList * m_pRmProtList;
  682. };
  683. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrProtocolList);
  684. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrProtocolList, IEnumRtrMgrProtocolInfo)
  685. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrProtocolList)
  686. HRESULT EnumRtrMgrProtocolList::Init(PRtrMgrProtocolInfoList *pRmProtList)
  687. {
  688. m_pRmProtList = pRmProtList;
  689. Reset();
  690. return hrOK;
  691. }
  692. HRESULT EnumRtrMgrProtocolList::Next(ULONG uNum, IRtrMgrProtocolInfo **ppRm, ULONG *pNumReturned)
  693. {
  694. Assert(uNum == 1);
  695. Assert(ppRm);
  696. HRESULT hr = hrOK;
  697. COM_PROTECT_TRY
  698. {
  699. if (m_pos)
  700. {
  701. *ppRm = m_pRmProtList->GetNext(m_pos);
  702. (*ppRm)->AddRef();
  703. if (pNumReturned)
  704. *pNumReturned = 1;
  705. hr = hrOK;
  706. }
  707. else
  708. {
  709. if (pNumReturned)
  710. *pNumReturned = 0;
  711. hr = hrFalse;
  712. }
  713. }
  714. COM_PROTECT_CATCH;
  715. return hr;
  716. }
  717. HRESULT EnumRtrMgrProtocolList::Skip(ULONG uNum)
  718. {
  719. Assert(uNum == 1);
  720. HRESULT hr = hrOK;
  721. COM_PROTECT_TRY
  722. {
  723. if (m_pos)
  724. {
  725. m_pRmProtList->GetNext(m_pos);
  726. }
  727. }
  728. COM_PROTECT_CATCH;
  729. return hr;
  730. }
  731. HRESULT EnumRtrMgrProtocolList::Reset()
  732. {
  733. HRESULT hr = hrOK;
  734. COM_PROTECT_TRY
  735. {
  736. m_pos = m_pRmProtList->GetHeadPosition();
  737. }
  738. COM_PROTECT_CATCH;
  739. return hr;
  740. }
  741. HRESULT EnumRtrMgrProtocolList::Clone(IEnumRtrMgrProtocolInfo **ppBlockEnum)
  742. {
  743. return E_NOTIMPL;
  744. }
  745. /*---------------------------------------------------------------------------
  746. Class: EnumInterfaceList
  747. Definition and implementation
  748. ---------------------------------------------------------------------------*/
  749. class EnumInterfaceList
  750. : public IEnumInterfaceInfo
  751. {
  752. public:
  753. DeclareIUnknownMembers(IMPL)
  754. DeclareIEnumInterfaceInfoMembers(IMPL)
  755. EnumInterfaceList() : m_cRef(1)
  756. {
  757. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumInterfaceList);
  758. }
  759. #ifdef DEBUG
  760. ~EnumInterfaceList()
  761. {
  762. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumInterfaceList);
  763. }
  764. #endif
  765. HRESULT Init(PInterfaceInfoList *pIfList);
  766. protected:
  767. LONG m_cRef;
  768. POSITION m_pos;
  769. PInterfaceInfoList * m_pIfList;
  770. };
  771. IMPLEMENT_ADDREF_RELEASE(EnumInterfaceList);
  772. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumInterfaceList, IEnumInterfaceInfo)
  773. DEBUG_DECLARE_INSTANCE_COUNTER(EnumInterfaceList)
  774. HRESULT EnumInterfaceList::Init(PInterfaceInfoList *pIfList)
  775. {
  776. m_pIfList = pIfList;
  777. Reset();
  778. return hrOK;
  779. }
  780. HRESULT EnumInterfaceList::Next(ULONG uNum, IInterfaceInfo **ppRm, ULONG *pNumReturned)
  781. {
  782. Assert(uNum == 1);
  783. Assert(ppRm);
  784. HRESULT hr = hrOK;
  785. COM_PROTECT_TRY
  786. {
  787. if (m_pos)
  788. {
  789. *ppRm = m_pIfList->GetNext(m_pos);
  790. (*ppRm)->AddRef();
  791. if (pNumReturned)
  792. *pNumReturned = 1;
  793. hr = hrOK;
  794. }
  795. else
  796. {
  797. if (pNumReturned)
  798. *pNumReturned = 0;
  799. hr = hrFalse;
  800. }
  801. }
  802. COM_PROTECT_CATCH;
  803. return hr;
  804. }
  805. HRESULT EnumInterfaceList::Skip(ULONG uNum)
  806. {
  807. Assert(uNum == 1);
  808. HRESULT hr = hrOK;
  809. COM_PROTECT_TRY
  810. {
  811. if (m_pos)
  812. {
  813. m_pIfList->GetNext(m_pos);
  814. }
  815. }
  816. COM_PROTECT_CATCH;
  817. return hr;
  818. }
  819. HRESULT EnumInterfaceList::Reset()
  820. {
  821. HRESULT hr = hrOK;
  822. COM_PROTECT_TRY
  823. {
  824. m_pos = m_pIfList->GetHeadPosition();
  825. }
  826. COM_PROTECT_CATCH;
  827. return hr;
  828. }
  829. HRESULT EnumInterfaceList::Clone(IEnumInterfaceInfo **ppBlockEnum)
  830. {
  831. return E_NOTIMPL;
  832. }
  833. /*---------------------------------------------------------------------------
  834. Class: EnumRtrMgrInterfaceList
  835. Definition and implementation
  836. ---------------------------------------------------------------------------*/
  837. class EnumRtrMgrInterfaceList
  838. : public IEnumRtrMgrInterfaceInfo
  839. {
  840. public:
  841. DeclareIUnknownMembers(IMPL)
  842. DeclareIEnumRtrMgrInterfaceInfoMembers(IMPL)
  843. EnumRtrMgrInterfaceList() : m_cRef(1)
  844. {
  845. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrInterfaceList);
  846. }
  847. #ifdef DEBUG
  848. ~EnumRtrMgrInterfaceList()
  849. {
  850. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrInterfaceList);
  851. }
  852. #endif
  853. HRESULT Init(PRtrMgrInterfaceInfoList *pRmIfList);
  854. protected:
  855. LONG m_cRef;
  856. POSITION m_pos;
  857. PRtrMgrInterfaceInfoList * m_pRmIfList;
  858. };
  859. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrInterfaceList);
  860. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrInterfaceList, IEnumRtrMgrInterfaceInfo)
  861. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrInterfaceList)
  862. HRESULT EnumRtrMgrInterfaceList::Init(PRtrMgrInterfaceInfoList *pRmIfList)
  863. {
  864. m_pRmIfList = pRmIfList;
  865. Reset();
  866. return hrOK;
  867. }
  868. HRESULT EnumRtrMgrInterfaceList::Next(ULONG uNum, IRtrMgrInterfaceInfo **ppRm, ULONG *pNumReturned)
  869. {
  870. Assert(uNum == 1);
  871. Assert(ppRm);
  872. HRESULT hr = hrOK;
  873. COM_PROTECT_TRY
  874. {
  875. if (m_pos)
  876. {
  877. *ppRm = m_pRmIfList->GetNext(m_pos);
  878. (*ppRm)->AddRef();
  879. if (pNumReturned)
  880. *pNumReturned = 1;
  881. hr = hrOK;
  882. }
  883. else
  884. {
  885. if (pNumReturned)
  886. *pNumReturned = 0;
  887. hr = hrFalse;
  888. }
  889. }
  890. COM_PROTECT_CATCH;
  891. return hr;
  892. }
  893. HRESULT EnumRtrMgrInterfaceList::Skip(ULONG uNum)
  894. {
  895. Assert(uNum == 1);
  896. HRESULT hr = hrOK;
  897. COM_PROTECT_TRY
  898. {
  899. if (m_pos)
  900. {
  901. m_pRmIfList->GetNext(m_pos);
  902. }
  903. }
  904. COM_PROTECT_CATCH;
  905. return hr;
  906. }
  907. HRESULT EnumRtrMgrInterfaceList::Reset()
  908. {
  909. HRESULT hr = hrOK;
  910. COM_PROTECT_TRY
  911. {
  912. m_pos = m_pRmIfList->GetHeadPosition();
  913. }
  914. COM_PROTECT_CATCH;
  915. return hr;
  916. }
  917. HRESULT EnumRtrMgrInterfaceList::Clone(IEnumRtrMgrInterfaceInfo **ppBlockEnum)
  918. {
  919. return E_NOTIMPL;
  920. }
  921. /*---------------------------------------------------------------------------
  922. Class: EnumRtrMgrProtocolInterfaceList
  923. Definition and implementation
  924. ---------------------------------------------------------------------------*/
  925. class EnumRtrMgrProtocolInterfaceList
  926. : public IEnumRtrMgrProtocolInterfaceInfo
  927. {
  928. public:
  929. DeclareIUnknownMembers(IMPL)
  930. DeclareIEnumRtrMgrProtocolInterfaceInfoMembers(IMPL)
  931. EnumRtrMgrProtocolInterfaceList() : m_cRef(1)
  932. {
  933. DEBUG_INCREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceList);
  934. }
  935. #ifdef DEBUG
  936. ~EnumRtrMgrProtocolInterfaceList()
  937. {
  938. DEBUG_DECREMENT_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceList);
  939. }
  940. #endif
  941. HRESULT Init(PRtrMgrProtocolInterfaceInfoList *pRmProtIfList);
  942. protected:
  943. LONG m_cRef;
  944. POSITION m_pos;
  945. PRtrMgrProtocolInterfaceInfoList * m_pRmProtIfList;
  946. };
  947. IMPLEMENT_ADDREF_RELEASE(EnumRtrMgrProtocolInterfaceList);
  948. IMPLEMENT_SIMPLE_QUERYINTERFACE(EnumRtrMgrProtocolInterfaceList, IEnumRtrMgrProtocolInterfaceInfo)
  949. DEBUG_DECLARE_INSTANCE_COUNTER(EnumRtrMgrProtocolInterfaceList)
  950. HRESULT EnumRtrMgrProtocolInterfaceList::Init(PRtrMgrProtocolInterfaceInfoList *pRmProtIfList)
  951. {
  952. m_pRmProtIfList = pRmProtIfList;
  953. Reset();
  954. return hrOK;
  955. }
  956. HRESULT EnumRtrMgrProtocolInterfaceList::Next(ULONG uNum, IRtrMgrProtocolInterfaceInfo **ppRm, ULONG *pNumReturned)
  957. {
  958. Assert(uNum == 1);
  959. Assert(ppRm);
  960. HRESULT hr = hrOK;
  961. COM_PROTECT_TRY
  962. {
  963. if (m_pos)
  964. {
  965. *ppRm = m_pRmProtIfList->GetNext(m_pos);
  966. (*ppRm)->AddRef();
  967. if (pNumReturned)
  968. *pNumReturned = 1;
  969. hr = hrOK;
  970. }
  971. else
  972. {
  973. if (pNumReturned)
  974. *pNumReturned = 0;
  975. hr = hrFalse;
  976. }
  977. }
  978. COM_PROTECT_CATCH;
  979. return hr;
  980. }
  981. HRESULT EnumRtrMgrProtocolInterfaceList::Skip(ULONG uNum)
  982. {
  983. Assert(uNum == 1);
  984. HRESULT hr = hrOK;
  985. COM_PROTECT_TRY
  986. {
  987. if (m_pos)
  988. {
  989. m_pRmProtIfList->GetNext(m_pos);
  990. }
  991. }
  992. COM_PROTECT_CATCH;
  993. return hr;
  994. }
  995. HRESULT EnumRtrMgrProtocolInterfaceList::Reset()
  996. {
  997. HRESULT hr = hrOK;
  998. COM_PROTECT_TRY
  999. {
  1000. m_pos = m_pRmProtIfList->GetHeadPosition();
  1001. }
  1002. COM_PROTECT_CATCH;
  1003. return hr;
  1004. }
  1005. HRESULT EnumRtrMgrProtocolInterfaceList::Clone(IEnumRtrMgrProtocolInterfaceInfo **ppBlockEnum)
  1006. {
  1007. return E_NOTIMPL;
  1008. }
  1009. /*!--------------------------------------------------------------------------
  1010. CreateEnumFromRmList
  1011. -
  1012. Author: KennT
  1013. ---------------------------------------------------------------------------*/
  1014. HRESULT CreateEnumFromRmList(RmDataList *pRmList, IEnumRtrMgrInfo **ppEnum)
  1015. {
  1016. Assert(pRmList);
  1017. Assert(ppEnum);
  1018. HRESULT hr = hrOK;
  1019. EnumRtrMgrList * pEnum;
  1020. pEnum = new EnumRtrMgrList;
  1021. hr = pEnum->Init(pRmList);
  1022. if (!FHrSucceeded(hr))
  1023. {
  1024. pEnum->Release();
  1025. pEnum = NULL;
  1026. }
  1027. *ppEnum = pEnum;
  1028. return hr;
  1029. }
  1030. /*!--------------------------------------------------------------------------
  1031. CreateEnumFromRtrMgrProtocolList
  1032. -
  1033. Author: KennT
  1034. ---------------------------------------------------------------------------*/
  1035. HRESULT CreateEnumFromRtrMgrProtocolList(PRtrMgrProtocolInfoList *pList, IEnumRtrMgrProtocolInfo **ppEnum)
  1036. {
  1037. Assert(pList);
  1038. Assert(ppEnum);
  1039. HRESULT hr = hrOK;
  1040. EnumRtrMgrProtocolList * pEnum;
  1041. pEnum = new EnumRtrMgrProtocolList;
  1042. hr = pEnum->Init(pList);
  1043. if (!FHrSucceeded(hr))
  1044. {
  1045. pEnum->Release();
  1046. pEnum = NULL;
  1047. }
  1048. *ppEnum = pEnum;
  1049. return hr;
  1050. }
  1051. /*!--------------------------------------------------------------------------
  1052. CreateEnumFromInterfaceList
  1053. -
  1054. Author: KennT
  1055. ---------------------------------------------------------------------------*/
  1056. HRESULT CreateEnumFromInterfaceList(PInterfaceInfoList *pList, IEnumInterfaceInfo **ppEnum)
  1057. {
  1058. Assert(pList);
  1059. Assert(ppEnum);
  1060. HRESULT hr = hrOK;
  1061. EnumInterfaceList * pEnum;
  1062. pEnum = new EnumInterfaceList;
  1063. hr = pEnum->Init(pList);
  1064. if (!FHrSucceeded(hr))
  1065. {
  1066. pEnum->Release();
  1067. pEnum = NULL;
  1068. }
  1069. *ppEnum = pEnum;
  1070. return hr;
  1071. }
  1072. /*!--------------------------------------------------------------------------
  1073. CreateEnumFromRtrMgrInterfaceList
  1074. -
  1075. Author: KennT
  1076. ---------------------------------------------------------------------------*/
  1077. HRESULT CreateEnumFromRtrMgrInterfaceList(PRtrMgrInterfaceInfoList *pList, IEnumRtrMgrInterfaceInfo **ppEnum)
  1078. {
  1079. Assert(pList);
  1080. Assert(ppEnum);
  1081. HRESULT hr = hrOK;
  1082. EnumRtrMgrInterfaceList * pEnum;
  1083. pEnum = new EnumRtrMgrInterfaceList;
  1084. hr = pEnum->Init(pList);
  1085. if (!FHrSucceeded(hr))
  1086. {
  1087. pEnum->Release();
  1088. pEnum = NULL;
  1089. }
  1090. *ppEnum = pEnum;
  1091. return hr;
  1092. }
  1093. /*!--------------------------------------------------------------------------
  1094. CreateEnumFromRtrMgrProtocolInterfaceList
  1095. -
  1096. Author: KennT
  1097. ---------------------------------------------------------------------------*/
  1098. HRESULT CreateEnumFromRtrMgrProtocolInterfaceList(PRtrMgrProtocolInterfaceInfoList *pList, IEnumRtrMgrProtocolInterfaceInfo **ppEnum)
  1099. {
  1100. Assert(pList);
  1101. Assert(ppEnum);
  1102. HRESULT hr = hrOK;
  1103. EnumRtrMgrProtocolInterfaceList * pEnum;
  1104. pEnum = new EnumRtrMgrProtocolInterfaceList;
  1105. hr = pEnum->Init(pList);
  1106. if (!FHrSucceeded(hr))
  1107. {
  1108. pEnum->Release();
  1109. pEnum = NULL;
  1110. }
  1111. *ppEnum = pEnum;
  1112. return hr;
  1113. }