⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftpdatatypes.cpp

📁 自己改写的在WINCE上开发用的EVC++的FTP操作示例工程,希望能给相关人士提供帮助.
💻 CPP
字号:
////////////////////////////////////////////////////////////////////////////////
// 
// Copyright (c) 2004 Thomas Oswald
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FTPDataTypes.h"

#ifdef __AFX_H__ // MFC only
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#endif

using namespace nsFTP;

/// returns the string which is used for display
CStringA CFirewallType::AsDisplayString() const
{
	switch( m_enFirewallType )
	{
	case ftNone:                              return "no firewall";
	case ftSiteHostName:                      return "SITE hostname";
	case ftUserAfterLogon:                    return "USER after logon";
	case ftProxyOpen:                         return "proxy OPEN";
	case ftTransparent:                       return "Transparent";
	case ftUserWithNoLogon:                   return "USER with no logon";
	case ftUserFireIDatRemotehost:            return "USER fireID@remotehost";
	case ftUserRemoteIDatRemoteHostFireID:    return "USER remoteID@remotehost fireID";
	case ftUserRemoteIDatFireIDatRemoteHost:  return "USER remoteID@fireID@remotehost";
	}
	ASSERT( false );
	return "";
}

/// return the string which is used for storage (e.g. in an XML- or INI-file)
CStringA CFirewallType::AsStorageString() const
{
	switch( m_enFirewallType )
	{
	case ftNone:                              return "NO_FIREWALL";
	case ftSiteHostName:                      return "SITE_HOSTNAME";
	case ftUserAfterLogon:                    return "USER_AFTER_LOGON";
	case ftProxyOpen:                         return "PROXY_OPEN";
	case ftTransparent:                       return "TRANSPARENT";
	case ftUserWithNoLogon:                   return "USER_WITH_NO_LOGON";
	case ftUserFireIDatRemotehost:            return "USER_FIREID@REMOTEHOST";
	case ftUserRemoteIDatRemoteHostFireID:    return "USER_REMOTEID@REMOTEHOST_FIREID";
	case ftUserRemoteIDatFireIDatRemoteHost:  return "USER_REMOTEID@FIREID@REMOTEHOST";
	}
	ASSERT( false );
	return "";
}

/// returns all available firewall types
void CFirewallType::GetAllTypes(TFirewallTypeVector& vTypes)
{
	vTypes.resize(9);
	vTypes[0] = ftNone;
	vTypes[1] = ftSiteHostName;
	vTypes[2] = ftUserAfterLogon;
	vTypes[3] = ftProxyOpen;
	vTypes[4] = ftTransparent;
	vTypes[5] = ftUserWithNoLogon;
	vTypes[6] = ftUserFireIDatRemotehost;
	vTypes[7] = ftUserRemoteIDatRemoteHostFireID;
	vTypes[8] = ftUserRemoteIDatFireIDatRemoteHost;
}

CLogonInfo::CLogonInfo() :
m_ushHostport(DEFAULT_FTP_PORT),
m_strUsername(ANONYMOUS_USER),
m_ushFwPort(DEFAULT_FTP_PORT),
m_FwType(CFirewallType::None())
{
}

CLogonInfo::CLogonInfo(const CStringA& strHostname, USHORT ushHostport, const CStringA& strUsername, 
					   const CStringA& strPassword, const CStringA& strAccount) :
m_strHostname(strHostname),
m_ushHostport(ushHostport),
m_strUsername(strUsername),
m_strPassword(strPassword),
m_strAccount(strAccount),
m_ushFwPort(DEFAULT_FTP_PORT),
m_FwType(CFirewallType::None())
{
}

CLogonInfo::CLogonInfo(const CStringA& strHostname, USHORT ushHostport, const CStringA& strUsername, const CStringA& strPassword,
					   const CStringA& strAccount, const CStringA& strFwHostname, const CStringA& strFwUsername, 
					   const CStringA& strFwPassword, USHORT ushFwPort, const CFirewallType& crFwType) :
m_strHostname(strHostname),
m_ushHostport(ushHostport),
m_strUsername(strUsername),
m_strPassword(strPassword),
m_strAccount(strAccount),
m_strFwHostname(strFwHostname),
m_strFwUsername(strFwUsername),
m_strFwPassword(strFwPassword),
m_ushFwPort(ushFwPort),
m_FwType(crFwType)
{
}

void CLogonInfo::SetHost(CStringA strHostname, USHORT ushHostport, CStringA strUsername, 
						 CStringA strPassword, CStringA strAccount)
{
	m_strHostname  = strHostname;
	m_ushHostport  = ushHostport;
	m_strUsername  = strUsername;
	m_strPassword  = strPassword;
	m_strAccount   = strAccount;
}

void CLogonInfo::SetFirewall(const CStringA& strFwHostname, const CStringA& strFwUsername, const CStringA& strFwPassword,
							 USHORT ushFwPort, const CFirewallType& crFwType)
{
	m_strFwHostname   = strFwHostname;
	m_strFwUsername   = strFwUsername;
	m_strFwPassword   = strFwPassword;
	m_ushFwPort       = ushFwPort;
	m_FwType          = crFwType;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -