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.

238 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. link.h
  5. Abstract:
  6. Link data class and link data class link list declarations. 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. #ifndef _LINK_H_
  15. #define _LINK_H_
  16. //------------------------------------------------------------------
  17. // Link data object. Each instance represents a web link in a
  18. // html document
  19. //
  20. class CLink
  21. {
  22. // Object specific enum
  23. public:
  24. // The object's state
  25. enum LinkState
  26. {
  27. eUnit, // uninitialize
  28. eUnsupport, // unsupport URL scheme
  29. eValidHTTP, // a valid HTTP link
  30. eValidURL, // a valid URL (except HTTP) link
  31. eInvalidHTTP, // invalid link due to HTTP status code
  32. eInvalidWininet // invalid link due to wininet API failure
  33. };
  34. // The content type of this web link
  35. enum ContentType
  36. {
  37. eBinary,
  38. eText
  39. };
  40. // Public interfaces
  41. public:
  42. // Constructor
  43. CLink(
  44. const CString& strURL, // URL
  45. const CString& strBase, // base URL used to generate the strURL
  46. const CString& strRelative, // relative URL used to generate the strURL
  47. BOOL fLocalLink
  48. );
  49. // Get the object's URL
  50. const CString& GetURL() const
  51. {
  52. return m_strURL;
  53. }
  54. // Set the object's URL
  55. void SetURL(
  56. const CString& strURL
  57. );
  58. // Get the object's base URL
  59. CString GetBase() const
  60. {
  61. return m_strBase;
  62. }
  63. // Get the object's relative URL
  64. const CString& GetRelative() const
  65. {
  66. return m_strRelative;
  67. }
  68. // Set the object state
  69. void SetState(
  70. LinkState state
  71. )
  72. {
  73. m_LinkState = state;
  74. }
  75. // Get the object state
  76. LinkState GetState() const
  77. {
  78. return m_LinkState;
  79. }
  80. // Get the current content type
  81. ContentType GetContentType() const
  82. {
  83. return m_ContentType;
  84. }
  85. // Set the current content type
  86. void SetContentType(
  87. ContentType type
  88. )
  89. {
  90. m_ContentType = type;
  91. }
  92. // Get the HTTP reponse status code or wininet last error code
  93. UINT GetStatusCode() const
  94. {
  95. return m_nStatusCode;
  96. }
  97. // Set the HTTP reponse status code or wininet last error code
  98. void SetStatusCode(
  99. UINT nStatusCode
  100. )
  101. {
  102. m_nStatusCode = nStatusCode;
  103. }
  104. // Get link data content
  105. CString GetData() const
  106. {
  107. return m_strData;
  108. }
  109. // Set link data content
  110. void SetData(
  111. CString strData
  112. )
  113. {
  114. m_strData = strData;
  115. }
  116. // Empty the link data content
  117. void EmptyData()
  118. {
  119. m_strData.Empty();
  120. }
  121. // Is this object represents a local link
  122. BOOL IsLocalLink() const
  123. {
  124. return m_fLocalLink;
  125. }
  126. // Get the object load time
  127. const CTime& GetTime() const
  128. {
  129. return m_Time;
  130. }
  131. // Set the object load time
  132. void SetTime(
  133. const CTime& Time
  134. )
  135. {
  136. m_Time = Time;
  137. }
  138. // Get the HTTP error status text of wininet error message
  139. const CString& GetStatusText() const
  140. {
  141. return m_strStatusText;
  142. }
  143. // Set the HTTP error status text of wininet error message
  144. void SetStatusText(
  145. LPCTSTR lpszStatusText
  146. )
  147. {
  148. m_strStatusText = lpszStatusText;
  149. }
  150. // Protected interfaces
  151. protected:
  152. // Preprocess the m_strURL to clean up "\r\n" and change '\' to '/'
  153. void PreprocessURL();
  154. // Protected members
  155. protected:
  156. CString m_strURL; // URL
  157. CString m_strBase; // base URL used to generate the strURL
  158. CString m_strRelative; // relative URL used to generate the strURL
  159. // Link data. We only read & store text file which will
  160. // parse for addtional link.
  161. CString m_strData;
  162. CString m_strStatusText; // the HTTP error status text of wininet error message
  163. UINT m_nStatusCode; // the HTTP reponse status code or wininet last error code
  164. LinkState m_LinkState; // current state of this object
  165. ContentType m_ContentType; // the link data content type
  166. BOOL m_fLocalLink; // is this a local link ?
  167. CTime m_Time; // object load time
  168. }; // class CLink
  169. //------------------------------------------------------------------
  170. // Link object pointer class
  171. //
  172. class CLinkPtrList : public CTypedPtrList<CPtrList, CLink*>
  173. {
  174. // Public funtions
  175. public:
  176. // Destructor
  177. ~CLinkPtrList();
  178. // Add link object to list
  179. void AddLink(
  180. const CString& strURL,
  181. const CString& strBase,
  182. const CString& strRelative,
  183. BOOL fLocalLink
  184. );
  185. }; // class CLinkPtrList
  186. #endif // _LINK_H_