亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ceinet.cpp

?? 這個程序是我編寫的從FTP站點下載文件的wince程序
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
	{
		Flush();
		InternetCloseHandle(m_hFile);
		_CESessionMap.RemoveKey(m_hFile);
		m_hFile = NULL;

		if (m_pbWriteBuffer != NULL)
		{
			delete [] m_pbWriteBuffer;
			m_pbWriteBuffer = NULL;
		}

		if (m_pbReadBuffer != NULL)
		{
			delete [] m_pbReadBuffer;
			m_pbReadBuffer = NULL;
		}
	}
}

UINT CCEInternetFile::Read(LPVOID lpBuf, UINT nCount)
{
	ASSERT_VALID(this);
	ASSERT(AfxIsValidAddress(lpBuf, nCount));
	ASSERT(m_hFile != NULL);
	ASSERT(m_bReadMode);

	DWORD dwBytes;

	if (!m_bReadMode || m_hFile == NULL)
		CEThrowInternetException(m_dwContext, ERROR_INVALID_HANDLE);

	if (m_pbReadBuffer == NULL)
	{
		if (!InternetReadFile(m_hFile, (LPVOID) lpBuf, nCount, &dwBytes))
				CEThrowInternetException(m_dwContext);
		return dwBytes;
	}

	LPBYTE lpbBuf = (LPBYTE) lpBuf;

	// if the requested size is bigger than our buffer,
	// then handle it directly

	if (nCount >= m_nReadBufferSize)
	{
		DWORD dwMoved = max(0, (long)m_nReadBufferBytes - (long)m_nReadBufferPos);
		WCE_FCTN(memcpy)(lpBuf, m_pbReadBuffer + m_nReadBufferPos, dwMoved);
		m_nReadBufferPos = m_nReadBufferSize;
		if (!InternetReadFile(m_hFile, lpbBuf+dwMoved, nCount-dwMoved, &dwBytes))
				CEThrowInternetException(m_dwContext);
		dwBytes += dwMoved;
	}
	else
	{
		if (m_nReadBufferPos + nCount >= m_nReadBufferBytes)
		{
			DWORD dwMoved = max(0, (long)m_nReadBufferBytes - (long)m_nReadBufferPos);
			WCE_FCTN(memcpy)(lpbBuf, m_pbReadBuffer + m_nReadBufferPos, dwMoved);

			DWORD dwRead;
			if (!InternetReadFile(m_hFile, m_pbReadBuffer, m_nReadBufferSize,
					&dwRead))
				CEThrowInternetException(m_dwContext);
			m_nReadBufferBytes = dwRead;

			dwRead = min(nCount - dwMoved, m_nReadBufferBytes);
			WCE_FCTN(memcpy)(lpbBuf + dwMoved, m_pbReadBuffer, dwRead);
			m_nReadBufferPos = dwRead;
			dwBytes = dwMoved + dwRead;
		}
		else
		{
			WCE_FCTN(memcpy)(lpbBuf, m_pbReadBuffer + m_nReadBufferPos, nCount);
			m_nReadBufferPos += nCount;
			dwBytes = nCount;
		}
	}

	return dwBytes;
}



LPTSTR CCEInternetFile::ReadString(LPTSTR pstr, UINT nMax)
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);
	ASSERT(AfxIsValidAddress(pstr, nMax*sizeof(TCHAR)));
	DWORD dwRead;

	// if we're reading line-by-line, we must have a buffer

	if (m_pbReadBuffer == NULL)
	{
		if (!SetReadBufferSize(4096))   // arbitrary but reasonable
			return NULL;
		if (!InternetReadFile(m_hFile, m_pbReadBuffer, m_nReadBufferSize,
				&dwRead))
			CEThrowInternetException(m_dwContext);
		m_nReadBufferBytes = dwRead;
		m_nReadBufferPos = 0;
	}

	LPTSTR pstrChar = (LPTSTR) (m_pbReadBuffer + m_nReadBufferPos);
	LPTSTR pstrTarget = pstr;

	while (--nMax)
	{
		if (m_nReadBufferPos >= m_nReadBufferBytes)
		{
			if (!InternetReadFile(m_hFile, m_pbReadBuffer, m_nReadBufferSize,
					&dwRead))
				CEThrowInternetException(m_dwContext);
			m_nReadBufferBytes = dwRead;
			if (m_nReadBufferBytes == 0)
			{
				*pstrTarget = '\0';
				if (pstrTarget == pstr)
					return NULL;
				else
					return pstr;
			}
			else
			{
				m_nReadBufferPos = 0;
				pstrChar = (LPTSTR) m_pbReadBuffer;
			}
		}

		if (*pstrChar != '\r')
			*pstrTarget++ = *pstrChar;

#if defined(_WIN32_WCE)
		m_nReadBufferPos += 2; // WinCE: for UNICODE characters
#else // _WIN32_WCE
		m_nReadBufferPos++;
#endif // _WIN32_WCE
		if (*pstrChar++ == '\n')
			break;
	}

	*pstrTarget = '\0';
	return pstr;
}

BOOL CCEInternetFile::ReadString(CString& rString)
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);

	rString = _T("");    // empty string without deallocating
	const int nMaxSize = 128;

	LPTSTR pstrPlace = rString.GetBuffer(nMaxSize);
	LPTSTR pstrResult;
	int nLen;

	do
	{
		pstrResult = ReadString(pstrPlace, nMaxSize);
		rString.ReleaseBuffer();

		// if string is read completely or EOF
		if (pstrResult == NULL ||
			(nLen = lstrlen(pstrPlace)) < (nMaxSize-1) ||
			pstrPlace[nLen-1] == '\n')
			break;

		nLen = rString.GetLength();
		pstrPlace = rString.GetBuffer(nMaxSize + nLen) + nLen;
	} while (1);

	// remove '\n' from end of string if present
	pstrPlace = rString.GetBuffer(0);
	nLen = rString.GetLength();
	if (nLen != 0 && pstrPlace[nLen-1] == '\n')
		pstrPlace[nLen-1] = '\0';
	rString.ReleaseBuffer();

	return (pstrResult != NULL);
}

DWORD CCEInternetFile::GetLength() const
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);

	DWORD dwRet = 0;

	if (m_hFile != NULL)
	{
		if (!InternetQueryDataAvailable(m_hFile, &dwRet, 0, 0))
			dwRet = 0;
	}

	return dwRet;
}

void CCEInternetFile::LockRange(DWORD /* dwPos */, DWORD /* dwCount */)
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);

	AfxThrowNotSupportedException();
}

void CCEInternetFile::UnlockRange(DWORD /* dwPos */, DWORD /* dwCount */)
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);

	AfxThrowNotSupportedException();
}

void CCEInternetFile::SetLength(DWORD)
{
	ASSERT_VALID(this);
	ASSERT(m_hFile != NULL);

	AfxThrowNotSupportedException();
}

CFile* CCEInternetFile::Duplicate() const
{
	ASSERT_VALID(this);
#if !defined(_WIN32_WCE)
	ASSERT(m_pStream != NULL);
#endif // _WIN32_WCE

	AfxThrowNotSupportedException();
	return NULL;
}

#ifdef _DEBUG
void CCEInternetFile::AssertValid() const
{
	// Don't call CStdioFile's AsssertValid()
	CFile::AssertValid();

#if !defined(_WIN32_WCE)
	ASSERT(m_hConnection != NULL);
#endif // _WIN32_WCE

	// make sure we really have a decent handle
	if (m_hFile != NULL)
	{
		DWORD dwResult = CEGetInternetHandleType(m_hFile);

		if (IsKindOf(RUNTIME_CLASS(CCEInternetFile)))
		{
			ASSERT(dwResult == INTERNET_HANDLE_TYPE_FTP_FILE ||
				dwResult == INTERNET_HANDLE_TYPE_FTP_FILE_HTML ||
				dwResult == INTERNET_HANDLE_TYPE_FTP_FIND_HTML ||
				dwResult == INTERNET_HANDLE_TYPE_HTTP_REQUEST);
		}
		else
			ASSERT(FALSE);  // some bogus object!
	}
}

void CCEInternetFile::Dump(CDumpContext& dc) const
{
	CObject::Dump(dc);

	dc << "\na " << GetRuntimeClass()->m_lpszClassName;
	dc << " with handle " << (UINT)m_hFile;
}
#endif

//___________________________________________________________________________


IMPLEMENT_DYNAMIC(CCEFtpFileFind, CObject)
void CCEFtpFileFind::Close()
{
	if (m_pFoundInfo != NULL)
	{
		delete m_pFoundInfo;
		m_pFoundInfo = NULL;
	}

	if (m_pNextInfo != NULL)
	{
		delete m_pNextInfo;
		m_pNextInfo = NULL;
	}

	if (m_hContext != NULL && m_hContext != INVALID_HANDLE_VALUE)
	{
		CloseContext();
		m_hContext = NULL;
	}
}

CCEFtpFileFind::CCEFtpFileFind(CCEFtpConnection* pConnection, DWORD dwContext)
{
	ASSERT(pConnection != NULL);
	ASSERT_KINDOF(CCEFtpConnection, pConnection);

	m_pFoundInfo = NULL;
	m_pNextInfo = NULL;
	m_hContext = NULL;

	m_pConnection = pConnection;
	if (dwContext == 1)
		dwContext = pConnection->GetContext();
	m_dwContext = dwContext;
	m_chDirSeparator = '/';
}

CCEFtpFileFind::~CCEFtpFileFind()
{
	Close();
}

BOOL CCEFtpFileFind::FindFile(LPCTSTR pstrName /* = NULL */,
	DWORD dwFlags /* = INTERNET_FLAG_RELOAD */)
{
	ASSERT((dwFlags & INTERNET_FLAG_ASYNC) == 0);
	ASSERT(m_pConnection != NULL);
	ASSERT_VALID(m_pConnection);

	if (m_pConnection == NULL)
		return FALSE;

	Close();
	m_pNextInfo = new WIN32_FIND_DATA;
	m_bGotLast = FALSE;

	if (pstrName == NULL)
		pstrName = _T("*");
	wcscpy(((LPWIN32_FIND_DATA) m_pNextInfo)->cFileName, pstrName);

	m_hContext = FtpFindFirstFile((HINTERNET) *m_pConnection,
		pstrName, (LPWIN32_FIND_DATA) m_pNextInfo, dwFlags, m_dwContext);

	if (m_hContext == NULL)
	{
		Close();
		return FALSE;
	}

	LPCTSTR pstrRoot = wcspbrk(pstrName, _T("\\/"));
	CString strCWD;
	m_pConnection->GetCurrentDirectory(strCWD);

	if (pstrRoot == NULL)
	{
		if (m_pConnection->SetCurrentDirectory(pstrName))
		{
			m_pConnection->GetCurrentDirectory(m_strRoot);
			m_pConnection->SetCurrentDirectory(strCWD);
		}
		else
			m_strRoot = strCWD;
	}
	else
	{
		// find the last forward or backward whack

		int nLast;
		LPCTSTR pstrOther = _tcsrchr(pstrName, '\\');
		pstrRoot = _tcsrchr(pstrName, '/');

		if (pstrRoot == NULL)
			pstrRoot = pstrName;
		if (pstrOther == NULL)
			pstrOther = pstrName;

		if (pstrRoot >= pstrOther)
			nLast = pstrRoot - pstrName;
		else
			nLast = pstrOther - pstrName;

		// from the start to the last whack is the root

		if (nLast == 0)
			nLast++;

		m_strRoot = pstrName;
		m_strRoot = m_strRoot.Left(nLast);
	}

	return TRUE;
}

BOOL CCEFtpFileFind::FindNextFile()
{
	ASSERT(m_hContext != NULL);
	if (m_hContext == NULL)
		return FALSE;

	if (m_pFoundInfo == NULL)
		m_pFoundInfo = new WIN32_FIND_DATA;

	ASSERT_VALID(this);
	void* pTemp = m_pFoundInfo;
	m_pFoundInfo = m_pNextInfo;
	m_pNextInfo = pTemp;

	return InternetFindNextFile(m_hContext, m_pNextInfo);
}

void CCEFtpFileFind::CloseContext()
{
	if (m_hContext != NULL && m_hContext != INVALID_HANDLE_VALUE)
	{
		InternetCloseHandle(m_hContext);
		m_hContext = NULL;
	}

	return;
}

CString CCEFtpFileFind::GetFileName() const
{
	ASSERT(m_hContext != NULL);
	ASSERT_VALID(this);

	CString ret;

	if (m_pFoundInfo != NULL)
		ret = ((LPWIN32_FIND_DATA) m_pFoundInfo)->cFileName;
	return ret;
}
CString CCEFtpFileFind::GetFilePath() const
{
	ASSERT(m_hContext != NULL);
	ASSERT_VALID(this);

	CString strResult = m_strRoot;
	if (strResult[strResult.GetLength()-1] != '\\' &&
		strResult[strResult.GetLength()-1] != '/')
		strResult += m_chDirSeparator;
	strResult += GetFileName();
	return strResult;
}

CString CCEFtpFileFind::GetFileURL() const
{
	ASSERT_VALID(this);
	ASSERT(m_hContext != NULL);

	CString str;

	if (m_hContext != NULL)
	{
		str += _CEURLftp;
		str += m_pConnection->GetServerName();
		str += GetFilePath();
	}

	return str;
}

#ifdef _DEBUG
void CCEFtpFileFind::Dump(CDumpContext& dc) const
{
	CObject::Dump(dc);
	dc << "m_hContext = " << m_hContext;
}

void CCEFtpFileFind::AssertValid() const
{
	CObject::AssertValid();
}
#endif

/////////////////////////////////////////////////////////////////////////////
// exception handling

void __stdcall CEThrowInternetException(DWORD dwContext, DWORD dwError /* = 0 */)
{
	if (dwError == 0)
		dwError = ::GetLastError();

	CCEInternetException* pException = new CCEInternetException(dwError);
	pException->m_dwContext = dwContext;

	TRACE1("Warning: throwing CCEInternetException for error %d\n", dwError);
	THROW(pException);
}

IMPLEMENT_DYNAMIC(CCEInternetException, CException)
BOOL CCEInternetException::GetErrorMessage(LPTSTR pstrError, UINT nMaxError,
		PUINT pnHelpContext)
{
	ASSERT(pstrError != NULL && AfxIsValidString(pstrError, nMaxError));

	if (pnHelpContext != NULL)
		*pnHelpContext = 0;

	LPTSTR lpBuffer;
	BOOL bRet = TRUE;

	HINSTANCE hWinINetLibrary;
	hWinINetLibrary = ::WCE_FCTN(LoadLibraryA)(WCE_IF(WCE_WININET_DLL,"WININET.DLL"));

	if (hWinINetLibrary == NULL ||
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
			hWinINetLibrary, m_dwError,
			MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
			(LPTSTR) &lpBuffer, 0, NULL) == 0)
	{
		// it failed! try Windows...

		bRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
			NULL,  m_dwError,
			MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
			(LPTSTR) &lpBuffer, 0, NULL);
	}

	if (!bRet)
		*pstrError = '\0';
	else
	{
		if (m_dwError == ERROR_INTERNET_EXTENDED_ERROR)
		{
			LPTSTR lpExtended;
			DWORD dwLength = 0;
			DWORD dwError;

			// find the length of the error
			if (!InternetGetLastResponseInfo(&dwError, NULL, &dwLength) &&
				GetLastError() == ERROR_INSUFFICIENT_BUFFER)
			{
				lpExtended = (LPTSTR) LocalAlloc(LPTR, dwLength);
				InternetGetLastResponseInfo(&dwError, lpExtended, &dwLength);
				wcsncpy(pstrError, lpExtended, nMaxError);
				pstrError += dwLength;
				nMaxError -= dwLength;
				if (nMaxError < 0)
					nMaxError = 0;
				LocalFree(lpExtended);
			}
			else
				TRACE0("Warning: Extended error reported with no response info\n");
			bRet = TRUE;
		}
		else
		{
			wcsncpy(pstrError, lpBuffer, nMaxError);
			bRet = TRUE;
		}

		LocalFree(lpBuffer);
	}

#ifndef _AFXDLL
	::FreeLibrary(hWinINetLibrary);
#endif
	return bRet;
}

CCEInternetException::CCEInternetException(DWORD dwError)
{
	m_dwError = dwError;
}

CCEInternetException::~CCEInternetException()
{
}

#ifdef _DEBUG
void CCEInternetException::Dump(CDumpContext& dc) const
{
	CObject::Dump(dc);

	dc << "m_dwError = " << m_dwError;
	dc << "\nm_dwContext = " << m_dwContext;
}
#endif












?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91免费观看视频在线| 午夜欧美一区二区三区在线播放| 国产精品国产成人国产三级| 一区二区三区四区蜜桃| 美国三级日本三级久久99| 福利电影一区二区三区| 欧美日韩色综合| 久久久影院官网| 亚洲二区在线观看| 国产成人免费在线视频| 欧美三级中文字幕| 久久精品这里都是精品| 亚洲午夜私人影院| 韩日精品视频一区| 欧美在线视频日韩| 久久久午夜精品理论片中文字幕| 亚洲精品免费看| 精品一区二区三区视频在线观看 | 91精品国产免费久久综合| 久久久久久久久久久久久夜| 亚洲国产三级在线| 国产福利视频一区二区三区| 91麻豆精品91久久久久久清纯| 欧美激情中文不卡| 石原莉奈在线亚洲三区| 成人av影院在线| 欧美v国产在线一区二区三区| 一区二区三区 在线观看视频| 国产高清成人在线| 欧美一级理论性理论a| 亚洲精品乱码久久久久久黑人| 久久99国产精品免费网站| 欧美吞精做爰啪啪高潮| 欧美国产一区在线| 久久爱www久久做| 欧美巨大另类极品videosbest| 国产精品久久久久久久久免费相片 | 国产不卡高清在线观看视频| 在线综合+亚洲+欧美中文字幕| 亚洲色图.com| 成人污视频在线观看| 亚洲精品在线一区二区| 青娱乐精品视频| 欧美人成免费网站| 亚洲与欧洲av电影| 9l国产精品久久久久麻豆| 久久久一区二区三区捆绑**| 美女精品自拍一二三四| 欧美精品一二三四| 亚洲一级片在线观看| 色哟哟一区二区三区| 中文字幕va一区二区三区| 精品一区二区日韩| 欧美xxxxx牲另类人与| 日本不卡不码高清免费观看| 欧美久久久久久蜜桃| 亚洲一区二区三区在线| 在线中文字幕一区| 亚洲区小说区图片区qvod| av电影一区二区| 国产精品不卡在线观看| 波波电影院一区二区三区| 国产人成一区二区三区影院| 国产一区二区电影| 国产日韩精品视频一区| 国产91富婆露脸刺激对白| 国产欧美日韩中文久久| 国产成人精品综合在线观看| 久久午夜电影网| 国产美女视频91| 国产欧美视频在线观看| 成人av网站在线| 日韩美女视频一区| 一本大道久久a久久精品综合| 亚洲特黄一级片| 色婷婷久久久综合中文字幕| 亚洲综合色噜噜狠狠| 欧美日本在线播放| 免费欧美日韩国产三级电影| 精品国产91乱码一区二区三区| 国产精品原创巨作av| 中文字幕乱码亚洲精品一区| aaa欧美大片| 一区二区三区中文字幕| 欧美手机在线视频| 日本人妖一区二区| 精品免费99久久| 国产高清精品在线| 亚洲乱码一区二区三区在线观看| 色八戒一区二区三区| 亚洲成av人片在线观看无码| 制服.丝袜.亚洲.中文.综合| 精品一区二区三区免费观看| 欧美激情一二三区| 欧美在线影院一区二区| 免费高清在线一区| 欧美国产精品久久| 欧美在线视频你懂得| 麻豆91在线播放| 国产欧美一区二区精品性色超碰| 99热99精品| 视频一区欧美精品| 国产欧美日韩视频一区二区| 91在线无精精品入口| 午夜激情久久久| 久久影视一区二区| 日本高清免费不卡视频| 青青草伊人久久| 国产精品久久久久婷婷二区次| 欧美性高清videossexo| 九九久久精品视频| 亚洲日本va在线观看| 欧美一个色资源| av动漫一区二区| 免费成人在线播放| 亚洲色图欧美偷拍| 日韩视频一区二区在线观看| 99久久久久免费精品国产| 日韩av成人高清| 亚洲欧洲无码一区二区三区| 91精品免费观看| 99精品国产91久久久久久| 日韩国产高清在线| 亚洲欧洲日韩av| 日韩免费成人网| 一本大道av一区二区在线播放 | 国产人成亚洲第一网站在线播放| 在线精品视频小说1| 国产一区二区免费在线| 午夜精彩视频在线观看不卡| 国产女主播视频一区二区| 欧美军同video69gay| av一区二区三区四区| 九一九一国产精品| 亚洲成人精品一区| √…a在线天堂一区| 久久人人爽爽爽人久久久| 欧美久久一二区| 色综合亚洲欧洲| 国产福利视频一区二区三区| 日本少妇一区二区| 一区二区激情小说| 国产精品美女久久久久久| 欧美成人精品高清在线播放| 欧美日韩一二三区| av一二三不卡影片| 国产盗摄女厕一区二区三区| 日韩成人午夜精品| 亚洲国产美国国产综合一区二区| 国产精品视频观看| 欧美精品一区二区三区很污很色的| 欧美乱熟臀69xxxxxx| 一本色道久久综合亚洲aⅴ蜜桃 | 亚洲欧美日韩国产综合在线| 久久你懂得1024| 欧美videofree性高清杂交| 欧美日韩激情一区二区| 日本高清视频一区二区| 99热这里都是精品| 成人av综合一区| 国产精品一区久久久久| 激情综合网最新| 青娱乐精品在线视频| 日韩中文字幕一区二区三区| 亚洲一区自拍偷拍| 亚洲精品高清在线观看| 亚洲人成在线观看一区二区| 成人欧美一区二区三区黑人麻豆| 国产日本一区二区| 久久精品日韩一区二区三区| 26uuu久久天堂性欧美| 日韩欧美成人一区| 欧美大片在线观看| 欧美成人猛片aaaaaaa| 日韩美女天天操| 日韩欧美一级精品久久| 欧美一区二区三区在线电影| 日韩一区二区在线观看视频| 日韩免费看网站| 精品乱码亚洲一区二区不卡| 精品少妇一区二区三区| 精品久久久影院| 久久精品在线观看| 日本一区二区三区电影| 国产精品毛片a∨一区二区三区| 日本一区二区电影| 国产精品午夜久久| 亚洲人快播电影网| 亚洲在线一区二区三区| 亚洲午夜成aⅴ人片| 日韩精品成人一区二区三区| 全部av―极品视觉盛宴亚洲| 麻豆91在线观看| 国产福利精品一区二区| eeuss鲁片一区二区三区| 91在线精品一区二区三区| 欧美亚洲动漫另类| 91精品国产欧美一区二区| 精品精品国产高清一毛片一天堂| 久久综合色婷婷|