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.

205 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. link.cpp
  5. Abstract:
  6. Link data class and link data class link list implementation. It
  7. encapsulates all the informations about a web link.
  8. Author:
  9. Michael Cheuk (mcheuk)
  10. Project:
  11. Link Checker
  12. Revision History:
  13. --*/
  14. #include "stdafx.h"
  15. #include "link.h"
  16. #include "lcmgr.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. CLink::CLink(
  23. const CString& strURL,
  24. const CString& strBase,
  25. const CString& strRelative,
  26. BOOL fLocalLink
  27. ):
  28. /*++
  29. Routine Description:
  30. Constructor.
  31. Arguments:
  32. strURL - URL
  33. strBase - Base URL
  34. strRelative - Relative URL
  35. fLocalLink - Is local link?
  36. Return Value:
  37. N/A
  38. --*/
  39. m_strURL(strURL),
  40. m_strBase(strBase),
  41. m_strRelative(strRelative),
  42. m_fLocalLink(fLocalLink)
  43. {
  44. m_LinkState = eUnit;
  45. m_ContentType = eBinary;
  46. m_nStatusCode = 0;
  47. PreprocessURL();
  48. } // CLink::CLink
  49. void
  50. CLink::SetURL(
  51. const CString& strURL
  52. )
  53. /*++
  54. Routine Description:
  55. Set the URL.
  56. Arguments:
  57. strURL - URL
  58. Return Value:
  59. N/A
  60. --*/
  61. {
  62. m_strURL = strURL;
  63. PreprocessURL();
  64. } // CLink::SetURL
  65. void
  66. CLink::PreprocessURL(
  67. )
  68. /*++
  69. Routine Description:
  70. Preprocess the m_strURL to clean up "\r\n" and change '\' to '/'
  71. Arguments:
  72. N/A
  73. Return Value:
  74. N/A
  75. --*/
  76. {
  77. // Change '\' to '\'
  78. CLinkCheckerMgr::ChangeBackSlash(m_strURL);
  79. // Remove all "\r\n" in the URL
  80. int iIndex = m_strURL.Find(_T("\r\n"));
  81. while(iIndex != -1)
  82. {
  83. m_strURL = m_strURL.Left(iIndex) + m_strURL.Mid(iIndex + _tcslen(_T("\r\n")));
  84. iIndex = m_strURL.Find(_T("\r\n"));
  85. }
  86. } // CLink::PreprocessURL
  87. CLinkPtrList::~CLinkPtrList(
  88. )
  89. /*++
  90. Routine Description:
  91. Destructor. Clean up all the object in link list.
  92. Arguments:
  93. N/A
  94. Return Value:
  95. N/A
  96. --*/
  97. {
  98. if(!IsEmpty())
  99. {
  100. POSITION Pos = GetHeadPosition();
  101. do
  102. {
  103. CLink* pLink = GetNext(Pos);
  104. delete pLink;
  105. }
  106. while(Pos != NULL);
  107. }
  108. } // CLinkPtrList::~CLinkPtrList
  109. void
  110. CLinkPtrList::AddLink(
  111. const CString& strURL,
  112. const CString& strBase,
  113. const CString& strRelative,
  114. BOOL fLocalLink)
  115. /*++
  116. Routine Description:
  117. Add link object to list
  118. Arguments:
  119. strURL - URL
  120. strBase - Base URL
  121. strRelative - Relative URL
  122. fLocalLink - Is local link?
  123. Return Value:
  124. N/A
  125. --*/
  126. {
  127. CLink* pLink = new CLink(strURL, strBase, strRelative, fLocalLink);
  128. if(pLink)
  129. {
  130. try
  131. {
  132. AddTail(pLink);
  133. }
  134. catch(CMemoryException* pEx)
  135. {
  136. pEx->Delete();
  137. }
  138. }
  139. } // CLinkPtrList::AddLink