📄 mmlcmd.cpp
字号:
if( NULL == pMsgPara)
{
ALLOCAL_MEMORY_FAILED;
return NULL;
}
memset(pMsgPara, 0, sizeof(TMsgPara));
return pMsgPara;
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TMmlcmd::printMmlcmd()
{
if(NULL == mmlContentHead)
{
PrintFormat(SPERROR, "MML cmd is empty");
return;
}
if( MIN_LEN_MML_HEAD > mmlLen || MAX_LEN_MML_CMD < mmlLen)
{
PrintFormat(SPERROR, "MML length=%d invalid", mmlLen);
return;
}
if( 0 >= paraNum )
{
PrintFormat(SPERROR, "MML not parameter");
return;
}
PrintFormat(PROMPT, "MML cmd len=%d content is:%s", mmlLen, mmlContentHead);
PrintFormat(PROMPT, "MML head is:%s have %d parameter", mmlHead,paraNum);
for(int i=0; i<paraNum; i++)
{
PrintFormat(PROMPT, "Parameter info List[%d] len=%d content is:%s",
i, strlen(paraInfoList[i]), paraInfoList[i]);
}
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TMmlcmd::parserMmlcmd()
{
if(NULL == mmlContent)
{
PrintFormat(SPERROR, "MML content is empty");
return;
}
mmlLen = strlen(mmlContent);
if(MAX_LEN_MML_CMD < mmlLen)
{
PrintFormat(SPERROR, "MML content too long length=%d", mmlLen);
return;
}
PrintFormat(PROMPT, "MML content is:%s", mmlContent);
if(MIN_LEN_MML_HEAD > mmlLen)
{
PrintFormat(SPERROR, "MML content too short length=%d", mmlLen);
return;
}
TChar *CurrPoint = mmlContent;
TChar *LastPoint = mmlContent;
TInt len = 0;
//分析MML命令头
CurrPoint = strchr(mmlContent, CHAR_COLON);
len = CurrPoint - LastPoint;
if(len < MIN_LEN_MML_HEAD || len > MAX_LEN_MML_HEAD)
{
PrintFormat(SPERROR, "MML invalid reason invalid head length=%d", len);
return;
}
memcpy(mmlHead, mmlContent, len);
//跳过':'字符
CurrPoint++;
len++;
mmlContent +=len;
LastPoint = mmlContent;
for(;;)
{
CurrPoint = strchr(mmlContent, CHAR_RBRACKET);
if(NULL == CurrPoint || NULL_CHAR == *CurrPoint)
{
PrintFormat(PROMPT,"MML not parameter or parser complete");
break;
}
CurrPoint += 2; //跳过')'和','两个字符
len = CurrPoint - LastPoint;
if(MIN_LEN_MML_HEAD > len)
{
PrintFormat(SPERROR, "MML have invalid paramter len=%d and "
"discard mml");
break;
}
TChar *paraInfo = NULL;
paraInfo = new TChar[len];
if(NULL == paraInfo)
{
ALLOCAL_MEMORY_FAILED;
return;
}
memset(paraInfo, NULL_CHAR, len);
memcpy(paraInfo, mmlContent, len-1);
paraList[paraNum].paraLen = len;
paraList[paraNum].paraInfo = paraInfo;
paraList[paraNum].paraInfoHead = paraInfo;
paraInfoList[paraNum] = paraInfo;
paraList[paraNum].parserParameter();
mmlContent +=len;
LastPoint = mmlContent;
paraNum++;
}
//printMmlcmd();
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmdList::TMmlcmdList()
{
mmlNum = 0;
mmlBuff = NULL;
mmlBuffLen = 0;
mmlBuffHead = NULL;
for(int i=0; i<MAX_NUM_MML_CMD; i++)
{
mmlContentList[i] = NULL;
}
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmdList::TMmlcmdList(TInt type)
{
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmdList::~TMmlcmdList()
{
if(NULL != mmlBuff)
{
delete [] mmlBuff;
mmlBuff = NULL;
}
for(int i=0; i<MAX_NUM_MML_CMD; i++)
{
mmlContentList[i] = NULL;
}
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TMmlcmdList::printMmlList()
{
if( NULL == mmlBuffHead || 0>= mmlBuffLen)
{
PrintFormat(SPERROR, "MML buffer is empty");
return;
}
if( 0 >= mmlNum )
{
PrintFormat(WARNING, "There aren't mml comand");
return;
}
PrintFormat(PROMPT, "MML buffer len=%d content is:%s", mmlBuffLen, mmlBuffHead);
PrintFormat(PROMPT, "There are %d items mml comand", mmlNum);
for(int i=0; i<mmlNum; i++)
{
PrintFormat(PROMPT, "MML List[%d] len=%d content is:%s",
i, strlen(mmlContentList[i]), mmlContentList[i]);
}
}
/*****************************************************
* Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TMmlcmdList::parserMmlList()
{
if(NULL == mmlBuff)
{
PrintFormat(SPERROR, "MML buffer is empty");
return;
}
if(MAX_LEN_BUFFER <= strlen(mmlBuff))
{
PrintFormat(SPERROR, "MML buffer too long");
return;
}
PrintFormat(PROMPT, "MML buffer is:%s", mmlBuff);
if(MAX_LEN_MML_HEAD > strlen(mmlBuff))
{
PrintFormat(SPERROR, "MML buffer content invalid reason too short");
return;
}
TChar *CurrPoint = mmlBuff;
TChar *LastPoint = mmlBuff;
TInt len = 0;
for(;;)
{
Start:
CurrPoint = strchr(mmlBuff, CHAR_SEMICOLON);
if(NULL == CurrPoint || NULL_CHAR == *CurrPoint)
{
PrintFormat(PROMPT,"MML buffer not end flag or parser complete");
break;
}
CurrPoint++;
len = CurrPoint - LastPoint;
if(MIN_LEN_MML_HEAD > len || MAX_LEN_MML_CMD < len)
{
PrintFormat(SPERROR, "MML buffer have invalid length=%d mml "
"and discard mml", len);
CurrPoint += len;
LastPoint += len;
mmlBuff += len;
goto Start;
}
TChar *mmlContent = NULL;
mmlContent = new TChar[len+1];
if(NULL == mmlContent)
{
ALLOCAL_MEMORY_FAILED;
return;
}
memset(mmlContent, NULL_CHAR, len+1);
memcpy(mmlContent, mmlBuff, len);
mmlCmdList[mmlNum].mmlContent = mmlContent;
mmlContentList[mmlNum] = mmlContent;
mmlCmdList[mmlNum].mmlContentHead = mmlContent;
mmlCmdList[mmlNum].parserMmlcmd();
mmlBuff += len;
LastPoint = mmlBuff;
mmlNum++;
}
//printMmlList();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -