76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
#include "StdAfx.h"
|
|
#include ".\ftpinfoparser.h"
|
|
#include "FtpInfo.h"
|
|
|
|
FtpInfoParser::FtpInfoParser(void)
|
|
{
|
|
m_XMLParser.Init();
|
|
m_FtpInfoHash.Initialize( MAX_FTP_CONNECT_COUNT );
|
|
}
|
|
|
|
FtpInfoParser::~FtpInfoParser(void)
|
|
{
|
|
UnLoad();
|
|
}
|
|
|
|
|
|
VOID FtpInfoParser::UnLoad()
|
|
{
|
|
FtpInfo* pFtpInfo = NULL;
|
|
|
|
for( FTP_INFO_HASH_ITER it = m_FtpInfoHash.begin(); it != m_FtpInfoHash.end(); ++it )
|
|
{
|
|
pFtpInfo = *it;
|
|
delete pFtpInfo;
|
|
}
|
|
|
|
m_FtpInfoHash.RemoveAll();
|
|
}
|
|
|
|
BOOL FtpInfoParser::Load( char* pszFileName )
|
|
{
|
|
if( !m_XMLParser.Load( pszFileName ) )
|
|
return FALSE;
|
|
|
|
long nFtpNum = 0;
|
|
NODELISTPtr pFtpNodeList = m_XMLParser.FindNodeList( L"//CONNECT", nFtpNum );
|
|
if( pFtpNodeList == NULL )
|
|
return FALSE;
|
|
|
|
BYTE byWorld = 0;
|
|
std::string strID, strPass, strIP, strName;
|
|
DWORD dwPort;
|
|
|
|
for( int i = 0; i < nFtpNum; i++ )
|
|
{
|
|
NODEPtr pConnectNode = m_XMLParser.FindNode( pFtpNodeList, i );
|
|
if( pConnectNode == NULL ) continue;
|
|
|
|
byWorld = 0;
|
|
strName.clear();
|
|
strID.clear();
|
|
strPass.clear();
|
|
strIP.clear();
|
|
dwPort = 0;
|
|
|
|
if( !m_XMLParser.GetAttriDataBYTE( pConnectNode, L"WORLD", byWorld ) ) continue;
|
|
if( !m_XMLParser.GetAttriDataStr( pConnectNode, L"NAME", strName ) ) continue;
|
|
if( !m_XMLParser.GetAttriDataStr( pConnectNode, L"IP", strIP ) ) continue;
|
|
if( !m_XMLParser.GetAttriDataDWORD( pConnectNode, L"PORT", dwPort ) ) continue;
|
|
if( !m_XMLParser.GetAttriDataStr( pConnectNode, L"ID", strID ) ) continue;
|
|
if( !m_XMLParser.GetAttriDataStr( pConnectNode, L"PASSWORD", strPass ) ) continue;
|
|
|
|
//FTP Á¤º¸¸¦ Ãß°¡ÇÑ´Ù.
|
|
FtpInfo* pInfo = new FtpInfo;
|
|
pInfo->SetWorld( byWorld );
|
|
pInfo->SetName( strName.c_str() );
|
|
pInfo->SetIP( strIP.c_str() );
|
|
pInfo->SetPort( (WORD)dwPort );
|
|
pInfo->SetID( strID.c_str() );
|
|
pInfo->SetPassWord( strPass.c_str() );
|
|
m_FtpInfoHash.Add( pInfo, byWorld );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|