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.

934 lines
22 KiB

  1. //****************************************************************************
  2. //
  3. // Module: ULS.DLL
  4. // File: attribs.cpp
  5. // Content: This file contains the attributes object.
  6. // History:
  7. // Wed 17-Apr-1996 11:13:54 -by- Viroon Touranachun [viroont]
  8. //
  9. // Copyright (c) Microsoft Corporation 1995-1996
  10. //
  11. //****************************************************************************
  12. #include "ulsp.h"
  13. #include "attribs.h"
  14. //****************************************************************************
  15. // CAttributes::CAttributes (void)
  16. //
  17. // History:
  18. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  19. // Created.
  20. // 12/05/96 -by- Chu, Lon-Chan [lonchanc]
  21. // Added access type.
  22. //****************************************************************************
  23. CAttributes::
  24. CAttributes ( VOID )
  25. :m_cRef (0),
  26. m_cAttrs (0),
  27. m_cchNames (0),
  28. m_cchValues (0),
  29. m_AccessType (ILS_ATTRTYPE_NAME_VALUE)
  30. {
  31. }
  32. //****************************************************************************
  33. // CAttributes::~CAttributes (void)
  34. //
  35. // History:
  36. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  37. // Created.
  38. //****************************************************************************
  39. CAttributes::~CAttributes (void)
  40. {
  41. ASSERT (m_cRef == 0);
  42. LPTSTR pszAttr;
  43. HANDLE hEnum;
  44. // Free all the attributes
  45. //
  46. m_AttrList.Enumerate(&hEnum);
  47. while (m_AttrList.Next(&hEnum, (LPVOID *)&pszAttr) == NOERROR)
  48. {
  49. ::MemFree (pszAttr);
  50. }
  51. m_AttrList.Flush();
  52. return;
  53. }
  54. //****************************************************************************
  55. // STDMETHODIMP
  56. // CAttributes::QueryInterface (REFIID riid, void **ppv)
  57. //
  58. // History:
  59. // Wed 17-Apr-1996 11:14:08 -by- Viroon Touranachun [viroont]
  60. // Created.
  61. //****************************************************************************
  62. STDMETHODIMP
  63. CAttributes::QueryInterface (REFIID riid, void **ppv)
  64. {
  65. *ppv = NULL;
  66. if (riid == IID_IIlsAttributes || riid == IID_IUnknown)
  67. {
  68. *ppv = (IIlsAttributes *) this;
  69. };
  70. if (*ppv != NULL)
  71. {
  72. ((LPUNKNOWN)*ppv)->AddRef();
  73. return S_OK;
  74. }
  75. else
  76. {
  77. return ILS_E_NO_INTERFACE;
  78. };
  79. }
  80. //****************************************************************************
  81. // STDMETHODIMP_(ULONG)
  82. // CAttributes::AddRef (void)
  83. //
  84. // History:
  85. // Wed 17-Apr-1996 11:14:17 -by- Viroon Touranachun [viroont]
  86. // Created.
  87. //****************************************************************************
  88. STDMETHODIMP_(ULONG)
  89. CAttributes::AddRef (void)
  90. {
  91. DllLock ();
  92. MyDebugMsg ((DM_REFCOUNT, "CAttribute::AddRef: ref=%ld\r\n", m_cRef));
  93. ::InterlockedIncrement (&m_cRef);
  94. return (ULONG) m_cRef;
  95. }
  96. //****************************************************************************
  97. // STDMETHODIMP_(ULONG)
  98. // CAttributes::Release (void)
  99. //
  100. // History:
  101. // Wed 17-Apr-1996 11:14:26 -by- Viroon Touranachun [viroont]
  102. // Created.
  103. //****************************************************************************
  104. STDMETHODIMP_(ULONG)
  105. CAttributes::Release (void)
  106. {
  107. DllRelease ();
  108. ASSERT (m_cRef > 0);
  109. MyDebugMsg ((DM_REFCOUNT, "CAttribute::Release: ref=%ld\r\n", m_cRef));
  110. if (::InterlockedDecrement (&m_cRef) == 0)
  111. {
  112. delete this;
  113. return 0;
  114. }
  115. return (ULONG) m_cRef;
  116. }
  117. //****************************************************************************
  118. // STDMETHODIMP
  119. // CAttributes::InternalSetAttribute (LPTSTR szName, LPTSTR szValue)
  120. //
  121. // History:
  122. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  123. // Created.
  124. //****************************************************************************
  125. HRESULT CAttributes::
  126. InternalSetAttribute ( TCHAR *pszName, TCHAR *pszValue )
  127. {
  128. ULONG cName, cValue;
  129. LPTSTR *ppszAttr;
  130. LPTSTR pszNewAttr;
  131. HANDLE hEnum;
  132. HRESULT hr;
  133. // Allocate the new attribute pair
  134. //
  135. cName = lstrlen(pszName);
  136. cValue = (pszValue != NULL) ? lstrlen (pszValue) : 0;
  137. pszNewAttr = (TCHAR *) ::MemAlloc (((cName+1) + (cValue+1)) * sizeof (TCHAR));
  138. if (pszNewAttr == NULL)
  139. {
  140. return ILS_E_MEMORY;
  141. };
  142. // Make the new attribute pair
  143. //
  144. lstrcpy(pszNewAttr, pszName);
  145. lstrcpy(pszNewAttr + cName + 1, (pszValue != NULL) ? pszValue : TEXT (""));
  146. // Look for the attribute in the list
  147. //
  148. hr = NOERROR;
  149. m_AttrList.Enumerate(&hEnum);
  150. while(m_AttrList.NextStorage(&hEnum, (PVOID *)&ppszAttr) == NOERROR)
  151. {
  152. // Match the attribute's name
  153. //
  154. if (!lstrcmpi(*ppszAttr, pszName))
  155. {
  156. // Found the specified attribute
  157. //
  158. break;
  159. };
  160. };
  161. if (ppszAttr != NULL)
  162. {
  163. // Replace the old pair
  164. //
  165. m_cchValues += (cValue + 1) -
  166. (lstrlen(((LPTSTR)*ppszAttr)+cName+1)+1);
  167. ::MemFree (*ppszAttr);
  168. *ppszAttr = pszNewAttr;
  169. }
  170. else
  171. {
  172. // Insert the new attribute pair
  173. //
  174. hr = m_AttrList.Insert(pszNewAttr);
  175. if (SUCCEEDED(hr))
  176. {
  177. // Update the name buffer count
  178. //
  179. m_cchNames += cName+1;
  180. m_cchValues += cValue+1;
  181. m_cAttrs++;
  182. }
  183. else
  184. {
  185. ::MemFree (pszNewAttr);
  186. };
  187. };
  188. return hr;
  189. }
  190. //****************************************************************************
  191. // HRESULT
  192. // CAttributes::InternalSetAttributeName ( TCHAR *pszName )
  193. //
  194. // History:
  195. // 12/06/96 -by- Chu, Lon-Chan [lonchanc]
  196. // Created.
  197. //****************************************************************************
  198. HRESULT CAttributes::
  199. InternalSetAttributeName ( TCHAR *pszName )
  200. {
  201. // We do not check for duplicate
  202. //
  203. HRESULT hr = m_AttrList.Insert (pszName);
  204. if (hr == S_OK)
  205. {
  206. // Update the name buffer count
  207. //
  208. m_cchNames += lstrlen (pszName) + 1;
  209. m_cAttrs++;
  210. }
  211. return hr;
  212. }
  213. //****************************************************************************
  214. // STDMETHODIMP
  215. // CAttributes::InternalRemoveAttribute (LPTSTR szName)
  216. //
  217. // History:
  218. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  219. // Created.
  220. //****************************************************************************
  221. HRESULT CAttributes::
  222. InternalCheckAttribute ( TCHAR *pszName, BOOL fRemove )
  223. {
  224. LPTSTR pszAttr;
  225. HANDLE hEnum;
  226. HRESULT hr;
  227. // Look for the attribute in the list
  228. //
  229. m_AttrList.Enumerate(&hEnum);
  230. while(m_AttrList.Next(&hEnum, (PVOID *)&pszAttr) == NOERROR)
  231. {
  232. // Match the attribute's name
  233. //
  234. if (! lstrcmpi(pszAttr, pszName))
  235. {
  236. // Found the specified attribute
  237. //
  238. break;
  239. };
  240. };
  241. // If found, we are asked to remove it, do so
  242. //
  243. if (pszAttr != NULL)
  244. {
  245. if (fRemove) {
  246. hr = m_AttrList.Remove(pszAttr);
  247. if (SUCCEEDED(hr))
  248. {
  249. ULONG cName;
  250. // Update the name buffer count
  251. //
  252. cName = lstrlen(pszName);
  253. m_cchNames -= cName+1;
  254. m_cchValues -= lstrlen(pszAttr+cName+1)+1;
  255. m_cAttrs--;
  256. ::MemFree (pszAttr);
  257. };
  258. }
  259. else {
  260. hr = S_OK;
  261. }
  262. }
  263. else
  264. {
  265. hr = S_FALSE;
  266. };
  267. return hr;
  268. }
  269. //****************************************************************************
  270. // STDMETHODIMP
  271. // CAttributes::SetAttribute (BSTR bstrName, BSTR bstrValue)
  272. //
  273. // History:
  274. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  275. // Created.
  276. // 12/06/96 -by- Chu, Lon-Chan [lonchanc]
  277. // Added access type.
  278. //****************************************************************************
  279. STDMETHODIMP CAttributes::
  280. SetAttribute ( BSTR bstrName, BSTR bstrValue )
  281. {
  282. LPTSTR szName;
  283. HRESULT hr;
  284. // Validate access type
  285. //
  286. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  287. return ILS_E_ACCESS_CONTROL;
  288. // Validate parameters
  289. //
  290. if (bstrName == NULL)
  291. return ILS_E_POINTER;
  292. if (*bstrName == '\0')
  293. return ILS_E_PARAMETER;
  294. // Convert the name format
  295. //
  296. hr = BSTR_to_LPTSTR(&szName, bstrName);
  297. if (SUCCEEDED(hr))
  298. {
  299. // If bstrValue is NULL, remove the attribute
  300. //
  301. if (bstrValue == NULL)
  302. {
  303. hr = InternalCheckAttribute(szName, TRUE);
  304. }
  305. else
  306. {
  307. LPTSTR szValue = NULL;
  308. if (bstrValue != NULL && *bstrValue != L'\0')
  309. hr = BSTR_to_LPTSTR(&szValue, bstrValue);
  310. if (SUCCEEDED(hr))
  311. {
  312. hr = InternalSetAttribute(szName, szValue);
  313. ::MemFree (szValue);
  314. };
  315. };
  316. // Free resources
  317. //
  318. ::MemFree (szName);
  319. };
  320. return hr;
  321. }
  322. //****************************************************************************
  323. // STDMETHODIMP
  324. // CAttributes::GetAttribute (BSTR bstrName, BSTR *pbstrValue)
  325. //
  326. // History:
  327. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  328. // Created.
  329. // 12/06/96 -by- Chu, Lon-Chan [lonchanc]
  330. // Added access type.
  331. //****************************************************************************
  332. STDMETHODIMP CAttributes::
  333. GetAttribute ( BSTR bstrName, BSTR *pbstrValue )
  334. {
  335. LPTSTR szName;
  336. HRESULT hr;
  337. // Validate access type
  338. //
  339. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  340. return ILS_E_ACCESS_CONTROL;
  341. // Validate parameters
  342. //
  343. if (pbstrValue == NULL)
  344. return ILS_E_POINTER;
  345. // Assume failure
  346. //
  347. *pbstrValue = NULL;
  348. // Validate more parameters
  349. //
  350. if (bstrName == NULL)
  351. return ILS_E_POINTER;
  352. if (*bstrName == '\0')
  353. return ILS_E_PARAMETER;
  354. // Convert the name format
  355. //
  356. hr = BSTR_to_LPTSTR(&szName, bstrName);
  357. if (SUCCEEDED(hr))
  358. {
  359. HANDLE hEnum;
  360. LPTSTR pszAttr;
  361. // Look for the attribute in the list
  362. //
  363. m_AttrList.Enumerate(&hEnum);
  364. while(m_AttrList.Next(&hEnum, (PVOID *)&pszAttr) == NOERROR)
  365. {
  366. // Match the attribute's name
  367. //
  368. if (!lstrcmpi(pszAttr, szName))
  369. {
  370. // Found the specified attribute
  371. //
  372. break;
  373. };
  374. };
  375. // If found, return the value
  376. //
  377. if (pszAttr != NULL)
  378. {
  379. hr = LPTSTR_to_BSTR(pbstrValue, pszAttr+lstrlen(pszAttr)+1);
  380. }
  381. else
  382. {
  383. hr = ILS_E_FAIL;
  384. };
  385. };
  386. // Free resources
  387. //
  388. ::MemFree (szName);
  389. return hr;
  390. }
  391. //****************************************************************************
  392. // STDMETHODIMP
  393. // CAttributes::EnumAttributes (IEnumIlsNames *pEnumAttribute)
  394. //
  395. // History:
  396. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  397. // Created.
  398. // 12/06/96 -by- Chu, Lon-Chan [lonchanc]
  399. // Added access type.
  400. //****************************************************************************
  401. STDMETHODIMP CAttributes::
  402. EnumAttributes ( IEnumIlsNames **ppEnumAttribute )
  403. {
  404. CEnumNames *pea;
  405. ULONG cAttrs, cbAttrs;
  406. LPTSTR pszAttrs;
  407. HRESULT hr;
  408. // Validate access type
  409. //
  410. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  411. return ILS_E_ACCESS_CONTROL;
  412. // Validate parameters
  413. //
  414. if (ppEnumAttribute == NULL)
  415. return ILS_E_POINTER;
  416. // Assume failure
  417. //
  418. *ppEnumAttribute = NULL;
  419. hr = GetAttributeList(&pszAttrs, &cAttrs, &cbAttrs);
  420. if (FAILED(hr))
  421. {
  422. return hr;
  423. };
  424. // Create a peer enumerator
  425. //
  426. pea = new CEnumNames;
  427. if (pea != NULL)
  428. {
  429. hr = pea->Init(pszAttrs, cAttrs);
  430. if (SUCCEEDED(hr))
  431. {
  432. // Get the enumerator interface
  433. //
  434. pea->AddRef();
  435. *ppEnumAttribute = pea;
  436. }
  437. else
  438. {
  439. delete pea;
  440. };
  441. }
  442. else
  443. {
  444. hr = ILS_E_MEMORY;
  445. };
  446. if (pszAttrs != NULL)
  447. {
  448. ::MemFree (pszAttrs);
  449. };
  450. return hr;
  451. }
  452. //****************************************************************************
  453. // STDMETHODIMP
  454. // CAttributes::SetAttributeName (BSTR bstrName)
  455. //
  456. // History:
  457. // 12/05/96 -by- Chu, Lon-Chan [lonchanc]
  458. // Created.
  459. //****************************************************************************
  460. STDMETHODIMP CAttributes::
  461. SetAttributeName ( BSTR bstrName )
  462. {
  463. TCHAR *pszName;
  464. HRESULT hr;
  465. // Validate access type
  466. //
  467. if (m_AccessType != ILS_ATTRTYPE_NAME_ONLY)
  468. return ILS_E_ACCESS_CONTROL;
  469. // Validate parameters
  470. //
  471. if (bstrName == NULL)
  472. return ILS_E_POINTER;
  473. if (*bstrName == '\0')
  474. return ILS_E_PARAMETER;
  475. // Convert the name format
  476. //
  477. if (BSTR_to_LPTSTR (&pszName, bstrName) != S_OK)
  478. return ILS_E_MEMORY;
  479. // Set the attribute name
  480. //
  481. return InternalSetAttributeName (pszName);
  482. }
  483. //****************************************************************************
  484. // STDMETHODIMP
  485. // CAttributes::GetAttributeList (LPTSTR *ppszList, ULONG *pcList, ULONG *pcb)
  486. // Get attribute names only.
  487. //
  488. // History:
  489. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  490. // Created.
  491. //****************************************************************************
  492. HRESULT CAttributes::
  493. GetAttributeList ( TCHAR **ppszList, ULONG *pcList, ULONG *pcb )
  494. {
  495. LPTSTR szAttrs, pszNext, pszAttr;
  496. HANDLE hEnum;
  497. #ifdef DEBUG
  498. ULONG cAttrsDbg = 0;
  499. #endif // DEBUG
  500. // Assume no list or failure
  501. //
  502. *ppszList = NULL;
  503. *pcList = 0;
  504. *pcb = 0;
  505. // If no list, return nothing
  506. //
  507. if (m_cAttrs == 0)
  508. {
  509. return NOERROR;
  510. };
  511. // Allocate the buffer for the attribute list
  512. //
  513. szAttrs = (TCHAR *) ::MemAlloc ((m_cchNames+1) * sizeof (TCHAR));
  514. if (szAttrs == NULL)
  515. {
  516. return ILS_E_MEMORY;
  517. };
  518. // Enumerate the list
  519. //
  520. pszNext = szAttrs;
  521. m_AttrList.Enumerate(&hEnum);
  522. while(m_AttrList.Next(&hEnum, (PVOID *)&pszAttr) == NOERROR)
  523. {
  524. // Attribute name
  525. //
  526. lstrcpy(pszNext, pszAttr);
  527. pszNext += lstrlen(pszNext)+1;
  528. #ifdef DEBUG
  529. cAttrsDbg++;
  530. #endif // DEBUG
  531. };
  532. *pszNext = '\0';
  533. ASSERT(cAttrsDbg == m_cAttrs);
  534. // return the attribute list
  535. //
  536. *pcList = m_cAttrs;
  537. *ppszList = szAttrs;
  538. *pcb = (m_cchNames+1)*sizeof(TCHAR);
  539. return NOERROR;
  540. }
  541. //****************************************************************************
  542. // STDMETHODIMP
  543. // CAttributes::GetAttributePairs (LPTSTR *ppszList, ULONG *pcList, ULONG *pcb)
  544. // Get pairs of attribute names and values.
  545. //
  546. // History:
  547. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  548. // Created.
  549. //****************************************************************************
  550. HRESULT CAttributes::
  551. GetAttributePairs ( TCHAR **ppszPairs, ULONG *pcList, ULONG *pcb )
  552. {
  553. LPTSTR szAttrs, pszNext, pszAttr;
  554. ULONG cLen;
  555. HANDLE hEnum;
  556. #ifdef DEBUG
  557. ULONG cAttrsDbg = 0;
  558. #endif // DEBUG
  559. // Validate access type
  560. //
  561. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  562. return ILS_E_ACCESS_CONTROL;
  563. // Assume no list or failure
  564. //
  565. *ppszPairs = NULL;
  566. *pcList = 0;
  567. *pcb = 0;
  568. // If no list, return nothing
  569. //
  570. if (m_cAttrs == 0)
  571. {
  572. return NOERROR;
  573. };
  574. // Allocate the buffer for the attribute list
  575. //
  576. szAttrs = (TCHAR *) ::MemAlloc ((m_cchNames+m_cchValues+1) * sizeof (TCHAR));
  577. if (szAttrs == NULL)
  578. {
  579. return ILS_E_MEMORY;
  580. };
  581. // Enumerate the list
  582. //
  583. pszNext = szAttrs;
  584. m_AttrList.Enumerate(&hEnum);
  585. while(m_AttrList.Next(&hEnum, (PVOID *)&pszAttr) == NOERROR)
  586. {
  587. // Attribute name
  588. //
  589. lstrcpy(pszNext, pszAttr);
  590. cLen = lstrlen(pszNext)+1;
  591. pszNext += cLen;
  592. // Attribute value
  593. //
  594. lstrcpy(pszNext, pszAttr+cLen);
  595. pszNext += lstrlen(pszNext)+1;
  596. #ifdef DEBUG
  597. cAttrsDbg++;
  598. #endif // DEBUG
  599. };
  600. *pszNext = '\0';
  601. ASSERT(cAttrsDbg == m_cAttrs);
  602. // return the attribute list
  603. //
  604. *pcList = m_cAttrs;
  605. *ppszPairs = szAttrs;
  606. *pcb = (m_cchNames+m_cchValues+1)*sizeof(TCHAR);
  607. return NOERROR;
  608. }
  609. //****************************************************************************
  610. // STDMETHODIMP
  611. // CAttributes::SetAttributePairs (LPTSTR pszList, ULONG cPair)
  612. //
  613. // History:
  614. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  615. // Created.
  616. //****************************************************************************
  617. HRESULT CAttributes::
  618. SetAttributePairs ( TCHAR *pszList, ULONG cPair )
  619. {
  620. LPTSTR pszName, pszValue;
  621. ULONG cLen, i;
  622. HRESULT hr;
  623. // Validate access type
  624. //
  625. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  626. return ILS_E_ACCESS_CONTROL;
  627. // Do nothing if nothing to set
  628. //
  629. if ((cPair == 0) ||
  630. (pszList == NULL))
  631. {
  632. return NOERROR;
  633. };
  634. pszName = pszList;
  635. for (i = 0; i < cPair; i++)
  636. {
  637. pszValue = pszName + lstrlen(pszName) + 1;
  638. InternalSetAttribute(pszName, pszValue);
  639. pszName = pszValue + lstrlen(pszValue) + 1;
  640. };
  641. return NOERROR;
  642. }
  643. //****************************************************************************
  644. // STDMETHODIMP
  645. // CAttributes::SetAttributes (CAttributes *pAttributes)
  646. //
  647. // History:
  648. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  649. // Created.
  650. //****************************************************************************
  651. HRESULT CAttributes::
  652. SetAttributes ( CAttributes *pAttrsEx )
  653. {
  654. LPTSTR pszNextAttr;
  655. HANDLE hEnum;
  656. HRESULT hr;
  657. // Validate access type
  658. //
  659. if (m_AccessType != ILS_ATTRTYPE_NAME_VALUE)
  660. return ILS_E_ACCESS_CONTROL;
  661. // Enumerate the external attribute list
  662. //
  663. pAttrsEx->m_AttrList.Enumerate(&hEnum);
  664. while(pAttrsEx->m_AttrList.Next(&hEnum, (PVOID *)&pszNextAttr) == NOERROR)
  665. {
  666. hr = InternalSetAttribute(pszNextAttr,
  667. pszNextAttr+lstrlen(pszNextAttr)+1);
  668. ASSERT(SUCCEEDED(hr));
  669. };
  670. return NOERROR;
  671. }
  672. //****************************************************************************
  673. // STDMETHODIMP
  674. // CAttributes::RemoveAttributes (CAttributes *pAttributes)
  675. //
  676. // History:
  677. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  678. // Created.
  679. //****************************************************************************
  680. HRESULT CAttributes::
  681. RemoveAttributes ( CAttributes *pAttrsEx )
  682. {
  683. LPTSTR pszNextAttr;
  684. HANDLE hEnum;
  685. // Enumerate the external attribute list
  686. //
  687. pAttrsEx->m_AttrList.Enumerate(&hEnum);
  688. while(pAttrsEx->m_AttrList.Next(&hEnum, (PVOID *)&pszNextAttr) == NOERROR)
  689. {
  690. InternalCheckAttribute(pszNextAttr, TRUE);
  691. };
  692. return NOERROR;
  693. }
  694. #ifdef MAYBE
  695. HRESULT CAttributes::
  696. SetOpsAttributes ( CAttributes *pAttrsEx, CAttributes **ppOverlap, CAttributes **ppIntersect )
  697. {
  698. LPTSTR pszNextAttr;
  699. HANDLE hEnum;
  700. BOOL fFullOverlap=FALSE, fNoOverlap = TRUE;
  701. // Enumerate the external attribute list
  702. //
  703. pAttrsEx->m_AttrList.Enumerate(&hEnum);
  704. while(pAttrsEx->m_AttrList.Next(&hEnum, (PVOID *)&pszNextAttr) == NOERROR)
  705. {
  706. if (InternalCheckAttribute(pszNextAttr, FALSE)!=S_OK) {
  707. // didn't find this attribute
  708. if (ppOverlap) {
  709. if (!*ppOverlap) {
  710. *ppOverlap = new CAttributes;
  711. if (!*ppOverlap) {
  712. goto bailout;
  713. }
  714. (*ppOverlap)->SetAccessType (ILS_ATTRTYPE_NAME_VALUE);
  715. }
  716. }
  717. }
  718. else {
  719. }
  720. };
  721. bailout:
  722. return NOERROR;
  723. }
  724. #endif //MAYBE
  725. #ifdef DEBUG
  726. //****************************************************************************
  727. // void
  728. // CAttributes::DebugOut (void)
  729. //
  730. // History:
  731. // Wed 17-Apr-1996 11:14:03 -by- Viroon Touranachun [viroont]
  732. // Created.
  733. //****************************************************************************
  734. void
  735. CAttributes::DebugOut (void)
  736. {
  737. LPTSTR pszNextAttr;
  738. HANDLE hEnum;
  739. // The attribute pair count
  740. //
  741. DPRINTF1(TEXT("Number of attributes: %d\r\n"), m_cAttrs);
  742. // Each attribute pair
  743. //
  744. m_AttrList.Enumerate(&hEnum);
  745. while(m_AttrList.Next(&hEnum, (PVOID *)&pszNextAttr) == NOERROR)
  746. {
  747. DPRINTF2(TEXT("\t<%s> = <%s>"), pszNextAttr,
  748. pszNextAttr+lstrlen(pszNextAttr)+1);
  749. };
  750. return;
  751. }
  752. #endif // DEBUG
  753. //****************************************************************************
  754. // STDMETHODIMP
  755. // CAttributes::Clone(IIlsAttibutes **ppAttributes)
  756. //
  757. // Synopsis:
  758. //
  759. // Arguments:
  760. //
  761. // Returns:
  762. //
  763. // History: 1/22/1997 Shishir Pardikar [shishirp] Created.
  764. //
  765. // Notes: this clones only attrib list which has both name and value
  766. //
  767. //****************************************************************************
  768. HRESULT
  769. CAttributes::CloneNameValueAttrib(CAttributes **ppAttributes)
  770. {
  771. CAttributes *pAttributes = NULL;
  772. HRESULT hr;
  773. if (ppAttributes == NULL) {
  774. return (ILS_E_PARAMETER);
  775. }
  776. *ppAttributes = NULL;
  777. pAttributes = new CAttributes;
  778. if (!pAttributes) {
  779. return (ILS_E_MEMORY);
  780. }
  781. pAttributes->SetAccessType (m_AccessType);
  782. hr = pAttributes->SetAttributes(this);
  783. if (!SUCCEEDED(hr)) {
  784. delete pAttributes;
  785. return hr;
  786. }
  787. *ppAttributes = pAttributes;
  788. return NOERROR;
  789. }