Files
2022-10-26 12:25:11 +08:00

86 lines
1.5 KiB
C++

#include ".\parameterpaser.h"
CParameterPaser::CParameterPaser(void)
{
m_bPasing = FALSE;
ZeroMemory( m_szValue, MAX_PARAM_COUNT*MAX_PATH_SIZE );
m_nCntParam = 0;
}
CParameterPaser::~CParameterPaser(void)
{
}
//인자로 들어온 값을 파싱한다.
BOOL CParameterPaser::ParseCommandLine (const char* lpszCmdLine)
{
if( lpszCmdLine == NULL || sizeof(lpszCmdLine) == 0 )
return FALSE;
char szTemp[MAX_PATH_SIZE];
int nTempPtr=0;
bool bInitParse = FALSE;
//현재 파서시키려는 커맨드 라인의 인자 개수 초기화.
m_nCntParam = 0;
for (int i = 0 ; lpszCmdLine[i] ; i++)
{
switch (lpszCmdLine[i])
{
case '<' :
bInitParse = TRUE;
break;
case '>' :
szTemp[nTempPtr] = 0;
if( m_nCntParam >= 10 )
return FALSE;
strncpy( m_szValue[m_nCntParam], szTemp, MAX_PATH_SIZE );
nTempPtr=0;
m_nCntParam++;
bInitParse = FALSE;
break;
default :
if (bInitParse)
{
szTemp[nTempPtr] = lpszCmdLine[i];
nTempPtr++;
}
break;
}
}
return TRUE;
}
BOOL CParameterPaser::CheckParameter()
{
if(!strcmp (m_szPath, ""))
{
MessageBox (NULL, "Excutable File Path Not Found.", "error", MB_OK | MB_ICONERROR);
return FALSE;
}
if(!strcmp (m_szIP, ""))
{
MessageBox (NULL, "Update Server IP Address Not Found.", "error", MB_OK | MB_ICONERROR);
return FALSE;
}
return TRUE;
}
void CParameterPaser::GetParameterInfo( char* pszValue, int nSize, int nParam )
{
if( nParam < 0 || nParam >= m_nCntParam )
return;
strncpy( pszValue, m_szValue[nParam], nSize );
}