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.

705 lines
20 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #ifndef __AFXINET_H_
  11. #define __AFXINET_H_
  12. #ifndef __AFX_H__
  13. #include <afx.h>
  14. #endif
  15. #ifndef _WININET_
  16. #pragma warning(disable: 4121)
  17. #include <wininet.h>
  18. #pragma warning(default: 4121)
  19. #endif
  20. #ifndef _AFXDLL
  21. #pragma comment(lib, "wininet.lib")
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // classes that are declared in this file
  25. class CInternetSession; // from CObject
  26. class CGopherLocator; // from CObject
  27. class CInternetFile; // from CStdioFile (FILETXT.CPP)
  28. class CHttpFile;
  29. class CGopherFile;
  30. class CInternetConnection;
  31. class CFtpConnection;
  32. class CGopherConnection;
  33. class CHttpConnection;
  34. class CFtpFileFind; // from CFileFind (FILEFIND.CPP)
  35. class CGopherFileFind;
  36. class CInternetException;
  37. /////////////////////////////////////////////////////////////////////////////
  38. #if _MFC_VER >= 0x0600
  39. #undef AFX_DATA
  40. #define AFX_DATA AFX_CORE_DATA
  41. #endif
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Global Functions
  44. BOOL AFXAPI AfxParseURL(LPCTSTR pstrURL, DWORD& dwServiceType,
  45. CString& strServer, CString& strObject, INTERNET_PORT& nPort);
  46. BOOL AFXAPI AfxParseURLEx(LPCTSTR pstrURL, DWORD& dwServiceType,
  47. CString& strServer, CString& strObject, INTERNET_PORT& nPort,
  48. CString& strUsername, CString& strPassword, DWORD dwFlags = 0);
  49. DWORD AFXAPI AfxGetInternetHandleType(HINTERNET hQuery);
  50. // see CInternetException at the bottom of this file
  51. void AFXAPI AfxThrowInternetException(DWORD_PTR dwContext, DWORD dwError = 0);
  52. // these are defined by WININET.H
  53. #define AFX_INET_SERVICE_FTP INTERNET_SERVICE_FTP
  54. #define AFX_INET_SERVICE_HTTP INTERNET_SERVICE_HTTP
  55. #define AFX_INET_SERVICE_GOPHER INTERNET_SERVICE_GOPHER
  56. // these are types that MFC parsing functions understand
  57. #define AFX_INET_SERVICE_UNK 0x1000
  58. #define AFX_INET_SERVICE_FILE (AFX_INET_SERVICE_UNK+1)
  59. #define AFX_INET_SERVICE_MAILTO (AFX_INET_SERVICE_UNK+2)
  60. #define AFX_INET_SERVICE_MID (AFX_INET_SERVICE_UNK+3)
  61. #define AFX_INET_SERVICE_CID (AFX_INET_SERVICE_UNK+4)
  62. #define AFX_INET_SERVICE_NEWS (AFX_INET_SERVICE_UNK+5)
  63. #define AFX_INET_SERVICE_NNTP (AFX_INET_SERVICE_UNK+6)
  64. #define AFX_INET_SERVICE_PROSPERO (AFX_INET_SERVICE_UNK+7)
  65. #define AFX_INET_SERVICE_TELNET (AFX_INET_SERVICE_UNK+8)
  66. #define AFX_INET_SERVICE_WAIS (AFX_INET_SERVICE_UNK+9)
  67. #define AFX_INET_SERVICE_AFS (AFX_INET_SERVICE_UNK+10)
  68. #define AFX_INET_SERVICE_HTTPS (AFX_INET_SERVICE_UNK+11)
  69. /////////////////////////////////////////////////////////////////////////////
  70. // classes that are declared in this file
  71. class CInternetSession : public CObject
  72. {
  73. public:
  74. CInternetSession(LPCTSTR pstrAgent = NULL,
  75. DWORD_PTR dwContext = 1,
  76. DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS,
  77. LPCTSTR pstrProxyName = NULL,
  78. LPCTSTR pstrProxyBypass = NULL,
  79. DWORD dwFlags = 0);
  80. BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  81. BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  82. BOOL QueryOption(DWORD dwOption, CString& refString) const;
  83. BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  84. DWORD dwFlags = 0);
  85. BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  86. CStdioFile* OpenURL(LPCTSTR pstrURL,
  87. DWORD_PTR dwContext = 1, DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII,
  88. LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLength = 0);
  89. CFtpConnection* GetFtpConnection(LPCTSTR pstrServer,
  90. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  91. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  92. BOOL bPassive = FALSE);
  93. CHttpConnection* GetHttpConnection(LPCTSTR pstrServer,
  94. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  95. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL);
  96. CHttpConnection* GetHttpConnection(LPCTSTR pstrServer, DWORD dwFlags,
  97. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  98. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL);
  99. CGopherConnection* GetGopherConnection(LPCTSTR pstrServer,
  100. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  101. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  102. BOOL EnableStatusCallback(BOOL bEnable = TRUE);
  103. DWORD ServiceTypeFromHandle(HINTERNET hQuery);
  104. // operations
  105. DWORD_PTR GetContext() const;
  106. operator HINTERNET() const;
  107. virtual void Close();
  108. #if _MFC_VER >= 0x0600
  109. // cookies
  110. static BOOL SetCookie(LPCTSTR pstrUrl, LPCTSTR pstrCookieName, LPCTSTR pstrCookieData);
  111. static BOOL GetCookie(LPCTSTR pstrUrl, LPCTSTR pstrCookieName, LPTSTR pstrCookieData, DWORD dwBufLen);
  112. static DWORD GetCookieLength(LPCTSTR pstrUrl, LPCTSTR pstrCookieName);
  113. static BOOL GetCookie(LPCTSTR pstrUrl, LPCTSTR pstrCookieName, CString& strCookieData);
  114. #endif
  115. // overridables
  116. virtual void OnStatusCallback(DWORD_PTR dwContext, DWORD dwInternetStatus,
  117. LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
  118. // implementation
  119. DECLARE_DYNAMIC(CInternetSession)
  120. ~CInternetSession();
  121. protected:
  122. DWORD_PTR m_dwContext;
  123. HINTERNET m_hSession;
  124. INTERNET_STATUS_CALLBACK m_pOldCallback;
  125. BOOL m_bCallbackEnabled;
  126. public:
  127. #ifdef _DEBUG
  128. virtual void Dump(CDumpContext& dc) const;
  129. #endif
  130. };
  131. ////////////////////////////////////////////////////////////////////////////
  132. // Internet File Access Wrapper
  133. class CInternetFile : public CStdioFile
  134. {
  135. // Constructors
  136. protected:
  137. CInternetFile(HINTERNET hFile, LPCTSTR pstrFileName,
  138. CInternetConnection* pConnection, BOOL bReadMode);
  139. CInternetFile(HINTERNET hFile, HINTERNET hSession,
  140. LPCTSTR pstrFileName, LPCTSTR pstrServer, DWORD_PTR dwContext,
  141. BOOL bReadMode);
  142. // Attributes
  143. protected:
  144. HINTERNET m_hFile;
  145. public:
  146. operator HINTERNET() const;
  147. DWORD_PTR GetContext() const;
  148. // Operations
  149. BOOL SetWriteBufferSize(UINT nWriteSize);
  150. BOOL SetReadBufferSize(UINT nReadSize);
  151. BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  152. BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  153. BOOL QueryOption(DWORD dwOption, CString& refString) const;
  154. BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  155. DWORD dwFlags = 0);
  156. BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  157. // Overridables
  158. virtual LONG Seek(LONG lOffset, UINT nFrom);
  159. virtual UINT Read(void* lpBuf, UINT nCount);
  160. virtual void Write(const void* lpBuf, UINT nCount);
  161. virtual void Abort();
  162. virtual void Flush();
  163. virtual void Close();
  164. virtual DWORD GetLength() const;
  165. virtual BOOL ReadString(CString& rString);
  166. virtual LPTSTR ReadString(LPTSTR pstr, UINT nMax);
  167. virtual void WriteString(LPCTSTR pstr);
  168. // Not supported by CInternetFile
  169. void LockRange(DWORD dwPos, DWORD dwCount);
  170. void UnlockRange(DWORD dwPos, DWORD dwCount);
  171. CFile* Duplicate() const;
  172. virtual void SetLength(DWORD dwNewLen);
  173. // Implementation
  174. public:
  175. virtual ~CInternetFile();
  176. protected:
  177. BOOL m_bReadMode;
  178. DWORD_PTR m_dwContext;
  179. HINTERNET m_hConnection;
  180. CString m_strServerName;
  181. UINT m_nWriteBufferSize;
  182. UINT m_nWriteBufferPos;
  183. LPBYTE m_pbWriteBuffer;
  184. UINT m_nReadBufferSize;
  185. UINT m_nReadBufferPos;
  186. LPBYTE m_pbReadBuffer;
  187. UINT m_nReadBufferBytes;
  188. #ifdef _DEBUG
  189. virtual void AssertValid() const;
  190. virtual void Dump(CDumpContext& dc) const;
  191. #endif
  192. friend class CInternetSession;
  193. friend class CFtpConnection;
  194. friend class CHttpConnection;
  195. friend class CGopherConnection;
  196. DECLARE_DYNAMIC(CInternetFile)
  197. };
  198. class CHttpFile : public CInternetFile
  199. {
  200. // Constructors
  201. protected:
  202. CHttpFile(HINTERNET hFile, HINTERNET hSession, LPCTSTR pstrObject,
  203. LPCTSTR pstrServer, LPCTSTR pstrVerb, DWORD_PTR dwContext);
  204. CHttpFile(HINTERNET hFile, LPCTSTR pstrVerb, LPCTSTR pstrObject,
  205. CHttpConnection* pConnection);
  206. // Operations
  207. public:
  208. BOOL AddRequestHeaders(LPCTSTR pstrHeaders,
  209. DWORD dwFlags = HTTP_ADDREQ_FLAG_ADD_IF_NEW, int dwHeadersLen = -1);
  210. BOOL AddRequestHeaders(CString& str,
  211. DWORD dwFlags = HTTP_ADDREQ_FLAG_ADD_IF_NEW);
  212. BOOL SendRequest(LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLen = 0,
  213. LPVOID lpOptional = NULL, DWORD dwOptionalLen = 0);
  214. BOOL SendRequest(CString& strHeaders,
  215. LPVOID lpOptional = NULL, DWORD dwOptionalLen = 0);
  216. #if _MFC_VER >= 0x0600
  217. BOOL SendRequestEx(DWORD dwTotalLen,
  218. DWORD dwFlags = HSR_INITIATE, DWORD_PTR dwContext = 1);
  219. BOOL SendRequestEx(LPINTERNET_BUFFERS lpBuffIn,
  220. LPINTERNET_BUFFERS lpBuffOut, DWORD dwFlags = HSR_INITIATE,
  221. DWORD_PTR dwContext = 1);
  222. BOOL EndRequest(DWORD dwFlags = 0,
  223. LPINTERNET_BUFFERS lpBuffIn = NULL, DWORD_PTR dwContext = 1);
  224. #endif
  225. BOOL QueryInfo(DWORD dwInfoLevel, LPVOID lpvBuffer,
  226. LPDWORD lpdwBufferLength, LPDWORD lpdwIndex = NULL) const;
  227. BOOL QueryInfo(DWORD dwInfoLevel, CString& str,
  228. LPDWORD dwIndex = NULL) const;
  229. BOOL QueryInfo(DWORD dwInfoLevel, SYSTEMTIME* pSysTime,
  230. LPDWORD dwIndex = NULL) const;
  231. BOOL QueryInfo(DWORD dwInfoLevel, DWORD& dwResult,
  232. LPDWORD dwIndex = NULL) const;
  233. BOOL QueryInfoStatusCode(DWORD& dwStatusCode) const;
  234. DWORD ErrorDlg(CWnd* pParent = NULL,
  235. DWORD dwError = ERROR_INTERNET_INCORRECT_PASSWORD,
  236. DWORD dwFlags = FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
  237. LPVOID* lppvData = NULL);
  238. // Attributes
  239. public:
  240. CString GetVerb() const;
  241. CString GetObject() const;
  242. virtual CString GetFileURL() const;
  243. virtual void Close();
  244. // Implementation
  245. public:
  246. virtual ~CHttpFile();
  247. protected:
  248. CString m_strObject;
  249. CString m_strVerb;
  250. #ifdef _DEBUG
  251. virtual void AssertValid() const;
  252. virtual void Dump(CDumpContext& dc) const;
  253. #endif
  254. friend class CHttpConnection;
  255. friend class CInternetSession;
  256. DECLARE_DYNAMIC(CHttpFile)
  257. };
  258. // class CGopherFile is declared after CGopherLocator, below
  259. ////////////////////////////////////////////////////////////////////////////
  260. // Connection types
  261. class CInternetConnection : public CObject
  262. {
  263. public:
  264. CInternetConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  265. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  266. DWORD_PTR dwContext = 1);
  267. // Operations
  268. operator HINTERNET() const;
  269. DWORD_PTR GetContext() const;
  270. CInternetSession* GetSession() const;
  271. CString GetServerName() const;
  272. BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  273. BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  274. BOOL QueryOption(DWORD dwOption, CString& refString) const;
  275. BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  276. DWORD dwFlags = 0);
  277. BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  278. // Implementation
  279. protected:
  280. HINTERNET m_hConnection;
  281. DWORD_PTR m_dwContext;
  282. CInternetSession* m_pSession;
  283. virtual void Close();
  284. CString m_strServerName;
  285. INTERNET_PORT m_nPort;
  286. public:
  287. ~CInternetConnection();
  288. DECLARE_DYNAMIC(CInternetConnection)
  289. #ifdef _DEBUG
  290. virtual void Dump(CDumpContext& dc) const;
  291. void AssertValid() const;
  292. #endif
  293. };
  294. class CFtpConnection : public CInternetConnection
  295. {
  296. public:
  297. CFtpConnection(CInternetSession* pSession, HINTERNET hConnected,
  298. LPCTSTR pstrServer, DWORD_PTR dwContext);
  299. CFtpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  300. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  301. DWORD_PTR dwContext = 0,
  302. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  303. BOOL bPassive = FALSE);
  304. BOOL SetCurrentDirectory(LPCTSTR pstrDirName);
  305. BOOL GetCurrentDirectory(CString& strDirName) const;
  306. BOOL GetCurrentDirectory(LPTSTR pstrDirName, LPDWORD lpdwLen) const;
  307. BOOL GetCurrentDirectoryAsURL(LPTSTR pstrName, LPDWORD lpdwLen) const;
  308. BOOL GetCurrentDirectoryAsURL(CString& strDirName) const;
  309. BOOL RemoveDirectory(LPCTSTR pstrDirName);
  310. BOOL CreateDirectory(LPCTSTR pstrDirName);
  311. BOOL Rename(LPCTSTR pstrExisting, LPCTSTR pstrNew);
  312. BOOL Remove(LPCTSTR pstrFileName);
  313. BOOL PutFile(LPCTSTR pstrLocalFile, LPCTSTR pstrRemoteFile,
  314. DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD_PTR dwContext = 1);
  315. BOOL GetFile(LPCTSTR pstrRemoteFile, LPCTSTR pstrLocalFile,
  316. BOOL bFailIfExists = TRUE,
  317. DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL,
  318. DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD_PTR dwContext = 1);
  319. CInternetFile* OpenFile(LPCTSTR pstrFileName,
  320. DWORD dwAccess = GENERIC_READ,
  321. DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD_PTR dwContext = 1);
  322. virtual void Close();
  323. // implementation
  324. ~CFtpConnection();
  325. protected:
  326. CString m_strServerName;
  327. public:
  328. #ifdef _DEBUG
  329. virtual void Dump(CDumpContext& dc) const;
  330. virtual void AssertValid() const;
  331. #endif
  332. DECLARE_DYNAMIC(CFtpConnection)
  333. };
  334. class CHttpConnection : public CInternetConnection
  335. {
  336. public:
  337. enum {
  338. _HTTP_VERB_MIN = 0,
  339. HTTP_VERB_POST = 0,
  340. HTTP_VERB_GET = 1,
  341. HTTP_VERB_HEAD = 2,
  342. HTTP_VERB_PUT = 3,
  343. HTTP_VERB_LINK = 4,
  344. HTTP_VERB_DELETE = 5,
  345. HTTP_VERB_UNLINK = 6,
  346. _HTTP_VERB_MAX = 6,
  347. };
  348. public:
  349. CHttpConnection(CInternetSession* pSession, HINTERNET hConnected,
  350. LPCTSTR pstrServer, DWORD_PTR dwContext);
  351. CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  352. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  353. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  354. DWORD_PTR dwContext = 1);
  355. CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  356. DWORD dwFlags, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  357. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  358. DWORD_PTR dwContext = 1);
  359. CHttpFile* OpenRequest(LPCTSTR pstrVerb, LPCTSTR pstrObjectName,
  360. LPCTSTR pstrReferer = NULL, DWORD_PTR dwContext = 1,
  361. LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
  362. DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT);
  363. CHttpFile* OpenRequest(int nVerb, LPCTSTR pstrObjectName,
  364. LPCTSTR pstrReferer = NULL, DWORD_PTR dwContext = 1,
  365. LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
  366. DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT);
  367. // implementation
  368. ~CHttpConnection();
  369. virtual void Close();
  370. protected:
  371. CString m_strServerName;
  372. static const LPCTSTR szHtmlVerbs[];
  373. public:
  374. #ifdef _DEBUG
  375. virtual void Dump(CDumpContext& dc) const;
  376. virtual void AssertValid() const;
  377. #endif
  378. friend class CInternetSession; // just to access szHtmlVerbs
  379. DECLARE_DYNAMIC(CHttpConnection)
  380. };
  381. class CGopherConnection : public CInternetConnection
  382. {
  383. public:
  384. CGopherConnection(CInternetSession* pSession,
  385. HINTERNET hConnected, LPCTSTR pstrServer, DWORD_PTR dwContext);
  386. CGopherConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  387. LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  388. DWORD_PTR dwContext = 0,
  389. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  390. CGopherFile* OpenFile(CGopherLocator& refLocator, DWORD dwFlags = 0,
  391. LPCTSTR pstrView = NULL, DWORD_PTR dwContext = 1);
  392. CGopherLocator CreateLocator(LPCTSTR pstrDisplayString,
  393. LPCTSTR pstrSelectorString, DWORD dwGopherType);
  394. BOOL CGopherConnection::GetAttribute(CGopherLocator& refLocator,
  395. CString strRequestedAttributes, CString& strResult);
  396. static CGopherLocator CreateLocator(LPCTSTR pstrLocator);
  397. static CGopherLocator CreateLocator(LPCTSTR pstrServerName,
  398. LPCTSTR pstrDisplayString,
  399. LPCTSTR pstrSelectorString, DWORD dwGopherType,
  400. INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  401. // implementation
  402. ~CGopherConnection();
  403. virtual void Close();
  404. public:
  405. #ifdef _DEBUG
  406. virtual void Dump(CDumpContext& dc) const;
  407. virtual void AssertValid() const;
  408. #endif
  409. DECLARE_DYNAMIC(CGopherConnection)
  410. };
  411. /////////////////////////////////////////////////////////////////////////////
  412. // CFtpFileFind
  413. class CFtpFileFind : public CFileFind
  414. {
  415. public:
  416. CFtpFileFind(CFtpConnection* pConnection, DWORD_PTR dwContext = 1);
  417. virtual ~CFtpFileFind();
  418. virtual BOOL FindFile(LPCTSTR pstrName = NULL,
  419. DWORD dwFlags = INTERNET_FLAG_RELOAD);
  420. virtual BOOL FindNextFile();
  421. CString GetFileURL() const;
  422. // implementation
  423. protected:
  424. virtual void CloseContext();
  425. CFtpConnection* m_pConnection;
  426. DWORD_PTR m_dwContext;
  427. public:
  428. #ifdef _DEBUG
  429. virtual void Dump(CDumpContext& dc) const;
  430. virtual void AssertValid() const;
  431. #endif
  432. DECLARE_DYNAMIC(CFtpFileFind)
  433. };
  434. /////////////////////////////////////////////////////////////////////////////
  435. // CGopherLocator
  436. class CGopherLocator : public CObject
  437. {
  438. public:
  439. ~CGopherLocator();
  440. operator LPCTSTR() const;
  441. CGopherLocator(const CGopherLocator& ref);
  442. BOOL GetLocatorType(DWORD& dwRef) const;
  443. private:
  444. // this only created by CGopherConnection::CreateLocator or by serialization
  445. CGopherLocator(LPCTSTR pstrLocator, DWORD dwLocLen);
  446. CString m_Locator; // _not_ a zero-terminated string!
  447. DWORD m_dwBufferLength;
  448. friend class CGopherConnection;
  449. friend class CGopherFile;
  450. };
  451. /////////////////////////////////////////////////////////////////////////////
  452. // CGopherFile
  453. class CGopherFile : public CInternetFile
  454. {
  455. // Constructors
  456. protected:
  457. CGopherFile(HINTERNET hFile, CGopherLocator& refLocator,
  458. CGopherConnection* pConnection);
  459. CGopherFile(HINTERNET hFile, HINTERNET hSession,
  460. LPCTSTR pstrLocator, DWORD dwLocLen, DWORD_PTR dwContext);
  461. // Operations
  462. public:
  463. virtual void Close();
  464. virtual void Write(const void* lpBuf, UINT nCount);
  465. void WriteString(LPCTSTR pstr);
  466. // Implementation
  467. protected:
  468. CGopherLocator m_Locator;
  469. public:
  470. virtual ~CGopherFile();
  471. #ifdef _DEBUG
  472. virtual void AssertValid() const;
  473. virtual void Dump(CDumpContext& dc) const;
  474. #endif
  475. friend class CInternetSession;
  476. friend class CGopherConnection;
  477. DECLARE_DYNAMIC(CGopherFile)
  478. };
  479. /////////////////////////////////////////////////////////////////////////////
  480. // CGopherFileFind
  481. class CGopherFileFind : public CFileFind
  482. {
  483. public:
  484. CGopherFileFind(CGopherConnection* pConnection, DWORD_PTR dwContext = 1);
  485. virtual ~CGopherFileFind();
  486. virtual BOOL FindFile(CGopherLocator& refLocator, LPCTSTR pstrString,
  487. DWORD dwFlags = INTERNET_FLAG_RELOAD);
  488. virtual BOOL FindFile(LPCTSTR pstrString,
  489. DWORD dwFlags = INTERNET_FLAG_RELOAD);
  490. virtual BOOL FindNextFile();
  491. virtual BOOL IsDots() const;
  492. virtual BOOL GetLastWriteTime(FILETIME* pTimeStamp) const;
  493. virtual BOOL GetLastAccessTime(FILETIME* pTimeStamp) const;
  494. virtual BOOL GetCreationTime(FILETIME* pTimeStamp) const;
  495. virtual BOOL GetLastWriteTime(CTime& refTime) const;
  496. virtual BOOL GetLastAccessTime(CTime& refTime) const;
  497. virtual BOOL GetCreationTime(CTime& refTime) const;
  498. CGopherLocator GetLocator() const;
  499. CString GetScreenName() const;
  500. virtual DWORD GetLength() const;
  501. #if defined(_X86_) || defined(_ALPHA_)
  502. virtual __int64 GetLength64() const;
  503. #endif
  504. protected:
  505. virtual void CloseContext();
  506. CGopherConnection* m_pConnection;
  507. DWORD_PTR m_dwContext;
  508. // implementation
  509. public:
  510. // Unsupported APIs
  511. CString GetFileName() const;
  512. CString GetFilePath() const;
  513. CString GetFileTitle() const;
  514. CString GetFileURL() const;
  515. CString GetRoot() const;
  516. #ifdef _DEBUG
  517. virtual void Dump(CDumpContext& dc) const;
  518. virtual void AssertValid() const;
  519. #endif
  520. DECLARE_DYNAMIC(CGopherFileFind)
  521. };
  522. ///////////////////////////////////////////////////////////////////////
  523. // CInternetException
  524. class CInternetException : public CException
  525. {
  526. public:
  527. // Constructor
  528. CInternetException(DWORD dwError);
  529. // Attributes
  530. DWORD m_dwError;
  531. DWORD_PTR m_dwContext;
  532. // Implementation
  533. public:
  534. ~CInternetException();
  535. #ifdef _DEBUG
  536. virtual void Dump(CDumpContext& dc) const;
  537. #endif
  538. virtual BOOL GetErrorMessage(LPTSTR lpstrError, UINT nMaxError,
  539. PUINT pnHelpContext = NULL);
  540. DECLARE_DYNAMIC(CInternetException)
  541. };
  542. /////////////////////////////////////////////////////////////////////////////
  543. // Inline function declarations
  544. #ifdef _AFX_ENABLE_INLINES
  545. #define _AFXINET_INLINE AFX_INLINE
  546. #include <afxinet.inl>
  547. #endif
  548. #undef AFX_DATA
  549. #define AFX_DATA
  550. #ifdef _AFX_MINREBUILD
  551. #pragma component(minrebuild, on)
  552. #endif
  553. #ifndef _AFX_FULLTYPEINFO
  554. #pragma component(mintypeinfo, off)
  555. #endif
  556. #endif // __AFXINET_H__