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

📄 flwparser.cpp

📁 flwscript解析器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			szOpCode[5]='\0';
			op= atoi(szOpCode);
			if(op==NSPROC) //等待按键,板卡操作返回
			{
				g_pstChnInfo[nIndex].m_iCurrentLine++;
				ret.m_nID=LP_FLW_WAIT;
				ret.m_nWaitID = LP_FLW_WAIT_FUNCTION;
				LogMesg(nIndex,"WAIT_FUNCTION  返回");
				return &ret;
			}
			OperateScript(nChnID,op);
			RETHDR*r = (RETHDR*)g_pstChnInfo[nIndex].m_stResult;
			if(r->m_nID==LP_FLW_FUNCTION)
			{
				g_pstChnInfo[nIndex].m_iCurrentLine++;
				LogMesg(nIndex,"LP_FLW_FUNCTION  返回");
				return r;
			}
			else if(r->m_nID==LP_FLW_HANGUP) 
			{
				LogMesg(nIndex,"解析到LP_FLW_HANGUP  返回");
				ret.m_nID=LP_FLW_HANGUP;
				ret.m_nWaitID = LP_FLW_HANGUP_VIOLATION;
				return &ret;
			}

			if(op ==HANGUPCALL)
			{
				LogMesg(nIndex,"HANGUPCALL");
				return &ret;
			}
			if(g_pstChnInfo[nIndex].m_nBlockSection==1)//阻止在关键区域之外
			{
				LogMesg(nIndex,"LP_FLW_WAIT_BLOCK  返回");
				ret.m_nID = LP_FLW_WAIT;
				ret.m_nWaitID = LP_FLW_WAIT_BLOCK;
				return &ret;
			}
			//应该继续走这个通道的流程,不应该走下一个通道
			if(g_pstChnInfo[nIndex].m_iIntVarLevel==0&&g_pstChnInfo[nIndex].m_iNextStateLine!=-1)
			{  
				LogMesg(nIndex,"LP_FLW_FUNCTION_GOTO  返回");
				g_pstChnInfo[nIndex].m_iCurrentLine++;
				MakeFunction(nIndex,LP_FLW_FUNCTION_GOTO);
				MakeGoto(nIndex,g_pstChnInfo[nIndex].m_iNextStateLine);
				RETHDR*r = (RETHDR*)g_pstChnInfo[nIndex].m_stResult;
				return r;
			}
			if(g_pstChnInfo[nIndex].m_iIntVarLevel==0&&g_pstChnInfo[nIndex].m_iNextStateLine==-1&&g_pstChnInfo[nIndex].m_nInitOK==1)
			{  
				LogMesg(nIndex,"LP_FLW_DEADSTATE1 返回");
				ret.m_nID = LP_FLW_DEADSTATE;
				return &ret;
			}
			
	}
	LogMesg(nIndex,"FP_StartFlw 返回");
	return &ret;
}

FLWPARSER_API RETHDR* FP_StartInitFlw(int nChnID)
{
	
	int nIndex = ChnMapTable[nChnID].m_nIndex;
	char szlog[1024]="";
	char szOpCode[100];
	int op;
	char  *pStmt=NULL;
	LogMesg(nIndex,"FP_StartInitFlw");
	memset(g_pstChnInfo[nIndex].m_stResult,0,1024); 
	for(;;g_pstChnInfo[nIndex].m_iCurrentLine++)
	{
		
			sprintf(szOpCode,"%s","");
			if(g_pstChnInfo[nIndex].m_iCurrentLine>g_pstChnInfo[nIndex].m_iFlowTotalLine)
			{
				ret.m_nID=LP_FLW_HANGUP;
				ret.m_nWaitID = LP_FLW_HANGUP_VIOLATION;
				return &ret;
			}
			g_pstChnInfo[nIndex].m_pStmt =GetLine(g_pstChnInfo[nIndex].m_nFlwID,g_pstChnInfo[nIndex].m_iCurrentLine,nIndex);
			if(g_pstChnInfo[nIndex].m_pStmt==NULL)
			{
				ret.m_nID=LP_FLW_HANGUP;
				ret.m_nWaitID = LP_FLW_HANGUP_VIOLATION;
				return &ret;
			}
			strncpy(szOpCode,g_pstChnInfo[nIndex].m_pStmt,5);
			szOpCode[5]='\0';
			op= atoi(szOpCode);
			if(op==NSTATE||op==AGENTDIGIT1||op==USERHANGUP1||op==USERCALLIN1||op==ONHOOK1||op==OFFHOOK1)//读到第一个state
			{
				//停留在state行
				/*
				if(m_iCurrentLine!=0)
					m_iCurrentLine--;//停留在state前一行;*/
				ret.m_nID = LP_FLW_DEADSTATE;
				return &ret;
			}
			OperateScript(nChnID,op);
	}
	return &ret;
}

FLWPARSER_API int FP_GetSpecialLineNo(int nFlwID ,int LineIdentifer)
{
	if(nFlwID>=0&&nFlwID<MAX_FLOW)
	{
		if(g_stCntInfo[nFlwID].m_nUse==0)
			return LP_ERROR_INVALIDFIWID;
	}
	else
		return LP_ERROR_INVALIDFIWID;
	int ReqLine = 0;
	switch(LineIdentifer)
	{
	case FP_LINE_HANGUP:
		ReqLine = g_stCntInfo[nFlwID].m_nHangUpLine;
		break;
	case FP_LINE_ONHOOK:
		ReqLine = g_stCntInfo[nFlwID].m_nOnHookLine;
		break;
	case FP_LINE_OFFHOOK:
		ReqLine = g_stCntInfo[nFlwID].m_nOffHookLine;
		break;
	case FP_LINE_USERHANGUP:
		ReqLine = g_stCntInfo[nFlwID].m_nUserHangUpLine;
		break;
	case FP_LINE_USERCALLIN:
		ReqLine = g_stCntInfo[nFlwID].m_nUserCallInLine;
		break;
	case FP_LINE_AGENTDIGIT:
		ReqLine = g_stCntInfo[nFlwID].m_nAgentDigitLine;
		break;
	case FP_LINE_AGENTEVENTPROC:
		ReqLine = g_stCntInfo[nFlwID].m_nAgentEventProcLine;
		break;
	case FP_LINE_WAITEVENTPROC:
		ReqLine = g_stCntInfo[nFlwID].m_nWaitEventProcLine;
		break;
	case FP_LINE_INTERSERVICE:
		ReqLine = g_stCntInfo[nFlwID].m_nInterServiceLine;
		break;
	default:
		return LP_ERROR_INVALIDLINEID;
	}
	return ReqLine;

}

FLWPARSER_API int FP_GetTimeOutLineNo(int nChnID)
{
	int nIndex = ChnMapTable[nChnID].m_nIndex;
	int ReqLine = g_pstChnInfo[nIndex].m_iTimeoutProcLine;
	char szlog[1024];
	sprintf(szlog,"FP_GetTimeOutLineNo(%d)",ReqLine);
	LogMesg(nIndex,szlog);
	return ReqLine;

}

FLWPARSER_API int FP_GetCurLineNo(int nChnID)
{
	int nIndex = ChnMapTable[nChnID].m_nIndex;
	int ReqLine = g_pstChnInfo[nIndex].m_iCurrentLine;
	char szlog[1024];
	sprintf(szlog,"FP_GetCurLineNo(%d)",ReqLine);
	LogMesg(nIndex,szlog);
	return ReqLine;

}
FLWPARSER_API int FP_InitFlw(int nFlwType,char*szAccessNo,char*szCompanyID,char*szFlwName,char* szFlowFile)
{
	int nCont =  GetFreeContNo();
	if(nCont<0||nCont>=MAX_FLOW)
		return LP_ERROR_OUTOFRANGE;//
	
	g_stCntInfo[nCont].m_nUse =1;
	g_stCntInfo[nCont].m_nStrCFlag = 0;
	g_stCntInfo[nCont].m_nSubFlowFlag=nFlwType;
	strcpy(g_stCntInfo[nCont].m_szCompanyID,szCompanyID);
	strcpy(g_stCntInfo[nCont].m_szAccessNo,szAccessNo);
	strcpy(g_stCntInfo[nCont].m_szFlowName,szFlwName);
	strcpy(g_stCntInfo[nCont].m_szFileName,szFlowFile);
	SetLastFileTime(nCont,szFlowFile);
	return ReadFlowFile(nCont,szFlowFile);
}

FLWPARSER_API int FP_SetFlwID(int nChnID,int nFlwID)
{
		int nIndex = ChnMapTable[nChnID].m_nIndex;
		g_pstChnInfo[nIndex].m_nFlwID = nFlwID;
		g_pstChnInfo[nIndex].m_iFlowTotalLine = g_stCntInfo[nFlwID].m_nMaxLine;
		return 1;
}
FLWPARSER_API int FP_DropPageVarible(int nChnID)
{
	DropAllPageVar( nChnID);

	return 1;
}
FLWPARSER_API int FP_DropStateVarible(int nChnID)
{
	int nIndex = ChnMapTable[nChnID].m_nIndex;
	while(g_pstChnInfo[nIndex].m_iIntVarLevel>0)
	{
		DecreaseVarHeap(nChnID);
	}
	return 1;
}
FLWPARSER_API int FP_SetIntResult(int nChnID,int nValue)
{
		char szlog[1024];
		int nIndex = ChnMapTable[nChnID].m_nIndex;
		g_pstChnInfo[nIndex].heap[g_pstChnInfo[nIndex].heapp++] = nValue;
		FP_SetIntVarible(nChnID,g_pstChnInfo[nIndex].szName,g_pstChnInfo[nIndex].heap[0]);
		sprintf(szlog,"FP_SetIntResult(%s,%d)",g_pstChnInfo[nIndex].szName,g_pstChnInfo[nIndex].heap[0]);
		LogMesg(nIndex,szlog);
		return 1;
}
FLWPARSER_API int FP_SetStringResult(int nChnID,char*pValue)
{
		char szlog[1024];
		int nIndex = ChnMapTable[nChnID].m_nIndex;
		strcat(g_pstChnInfo[nIndex].szResult ,pValue);
		FP_SetStringVarible(nChnID,g_pstChnInfo[nIndex].szName,g_pstChnInfo[nIndex].szResult);
		sprintf(szlog,"FP_SetStringResult(%s,%s)",g_pstChnInfo[nIndex].szName,g_pstChnInfo[nIndex].szResult);
		LogMesg(nIndex,szlog);
		return 1;
}
FLWPARSER_API int FP_SetCurrentLineNo(int nChnID,int nLineNo)
{
	int nIndex = ChnMapTable[nChnID].m_nIndex;
	g_pstChnInfo[nIndex].m_iCurrentLine = nLineNo;
	return 1;
}

FLWPARSER_API int FP_FreeFlw(int nFlwID)
{
	return 1;
}
FLWPARSER_API int FP_GetFreeFlwID()
{
	return GetFreeContNo();
}
FLWPARSER_API int FP_SetChnIDByIndex(int nIndex,int nChnID)
{
	g_pstChnInfo[nIndex].m_nChnID = nChnID;
	ChnMapTable[nChnID].m_nIndex = nIndex;
	return 1;
}
FLWPARSER_API int FP_InitChn(int nChnID)
{

	int nIndex = ChnMapTable[nChnID].m_nIndex;
	g_pstChnInfo[nIndex].m_nInitOK = 0;
	//memset(g_pstChnInfo[nIndex],0,sizeof(CALL));
	g_pstChnInfo[nIndex].m_bCheckTime = 0;
	g_pstChnInfo[nIndex].m_bFilePlayTimeFlag = 0;
	g_pstChnInfo[nIndex].m_bInConf = 0;
	g_pstChnInfo[nIndex].m_bInMultiConf = 0;
	g_pstChnInfo[nIndex].m_bInUse =0;
	g_pstChnInfo[nIndex].m_bIsInit = 0;
	g_pstChnInfo[nIndex].m_bNetMsgComing = 0;
	g_pstChnInfo[nIndex].m_bSleepFlag = 0;
	g_pstChnInfo[nIndex].m_bTalking = 0;
	g_pstChnInfo[nIndex].m_bWaitFlag = 0;
	g_pstChnInfo[nIndex].m_HangUpFlag = 0;
	g_pstChnInfo[nIndex].m_iCurrentLine = 0;
	g_pstChnInfo[nIndex].m_iDialOutResult= 0;
	g_pstChnInfo[nIndex].m_iDialOutType = 0;
	g_pstChnInfo[nIndex].m_iFlowTotalLine =0;
	g_pstChnInfo[nIndex].m_iIfResult= 0;
	g_pstChnInfo[nIndex].m_iInit = 0;
	g_pstChnInfo[nIndex].m_iIntVarCount=0;
	g_pstChnInfo[nIndex].m_iIntVarLevel= 0;
	g_pstChnInfo[nIndex].m_iLeaveFlag = 0;
	g_pstChnInfo[nIndex].m_iNextStateLine = -1;
	g_pstChnInfo[nIndex].m_iStringVarCount = 0;
	g_pstChnInfo[nIndex].m_iStringVarLevel = 0;
	g_pstChnInfo[nIndex].m_iTimeoutProcLine = 0;
	g_pstChnInfo[nIndex].m_nAgentHangUpFlag = 0;
	g_pstChnInfo[nIndex].m_nAgentLine=0;
	g_pstChnInfo[nIndex].m_nBlockSection=0;
//	g_pstChnInfo[nIndex].m_nBoolResult = 0;
	g_pstChnInfo[nIndex].m_nBoolResultTop = 0;
	g_pstChnInfo[nIndex].m_nChanState = 0;
	g_pstChnInfo[nIndex].m_nChnID = 0;
	g_pstChnInfo[nIndex].m_nConfNo = 0;
	g_pstChnInfo[nIndex].m_nConnID =0;
	g_pstChnInfo[nIndex].m_nDbExFeeValue =0;
	g_pstChnInfo[nIndex].m_nDbDialCount = 0;
	g_pstChnInfo[nIndex].m_nDbFeeValue = 0;
	g_pstChnInfo[nIndex].m_nDbFlag = 0;
	g_pstChnInfo[nIndex].m_nDbID = 0;
	g_pstChnInfo[nIndex].m_nDbOrderType = 0;
	g_pstChnInfo[nIndex].m_nDbSex = 0;
	g_pstChnInfo[nIndex].m_nDestChan = 0;
	g_pstChnInfo[nIndex].m_nDestTermNo = 0;
	g_pstChnInfo[nIndex].m_nDialCountFlag = 0;
	g_pstChnInfo[nIndex].m_nDigitNum = 0;
	g_pstChnInfo[nIndex].m_nEventTime = 0;
	g_pstChnInfo[nIndex].m_nFlowState =0;
	g_pstChnInfo[nIndex].m_nFlwID = -1;
	g_pstChnInfo[nIndex].m_nFreeTime = 0;
	g_pstChnInfo[nIndex].m_nGotoFlag = 0;
	g_pstChnInfo[nIndex].m_nHangUpError = 0;
g_pstChnInfo[nIndex].m_nInSection = 0;
g_pstChnInfo[nIndex].m_nIpChanNo = 0;
g_pstChnInfo[nIndex].m_nLevelTemp = 0;
g_pstChnInfo[nIndex].m_nLineEventCode = 0;
g_pstChnInfo[nIndex].m_nLineLevel = 0;
g_pstChnInfo[nIndex].m_nLineNo= 0;
g_pstChnInfo[nIndex].m_nLineState = 0;
g_pstChnInfo[nIndex].m_nMusicCount = 0;
g_pstChnInfo[nIndex].m_nMusicId = 0;
g_pstChnInfo[nIndex].m_nNetMsgResult = 0;
g_pstChnInfo[nIndex].m_nNetStatus = 0;
g_pstChnInfo[nIndex].m_nPriority = 0;
g_pstChnInfo[nIndex].m_nProcEvent = 0;
g_pstChnInfo[nIndex].m_nRecordLine = 0;
g_pstChnInfo[nIndex].m_nSetScale = 0;
g_pstChnInfo[nIndex].m_nSleepSeconds = 0;
g_pstChnInfo[nIndex].m_nSqlAffectedRol = 0;
g_pstChnInfo[nIndex].m_nSqlAffectedRow = 0;
g_pstChnInfo[nIndex].m_nSqlOpFlag = 0;
g_pstChnInfo[nIndex].m_nUserCallInFlag = 0;
g_pstChnInfo[nIndex].m_nUserHangUpFlag = 0;
g_pstChnInfo[nIndex].m_nWaitCount = 0;
g_pstChnInfo[nIndex].m_nWaitMaxCount = 0;
g_pstChnInfo[nIndex].m_nWaitTime = 0;

	//g_pstChnInfo[nIndex].
	strcpy(g_pstChnInfo[nIndex].m_sSubFlow,"");
	strcpy(g_pstChnInfo[nIndex].m_szAccessNo,"");
	strcpy(g_pstChnInfo[nIndex].m_szAgentCallOutFlowName,"");
	strcpy(g_pstChnInfo[nIndex].m_szAgentID,"");
	strcpy(g_pstChnInfo[nIndex].m_szCalledNum,"");
	strcpy(g_pstChnInfo[nIndex].m_szCalledRecord,"");
	strcpy(g_pstChnInfo[nIndex].m_szCallerNum,"");
	strcpy(g_pstChnInfo[nIndex].m_szCallerRecord,"");
	strcpy(g_pstChnInfo[nIndex].m_szCallID,"");
	strcpy(g_pstChnInfo[nIndex].m_szCompany,"");
	strcpy(g_pstChnInfo[nIndex].m_szCompanyID,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbAccessNo,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbCalledMobile,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbCallerMobile,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbCompanyId,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbDialTime,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbDisplayMobile,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbExServiceType,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbLeaveWord,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbLinkId,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbName,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbPrivateData,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbServiceType,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbSmsCode,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbSmsMsg,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbSmsSender,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbSongId,"");
	strcpy(g_pstChnInfo[nIndex].m_szDbSubFlow,"");
	strcpy(g_pstChnInfo[nIndex].m_szDialInTime,"");
	strcpy(g_pstChnInfo[nIndex].m_szDialNum,"");
	strcpy(g_pstChnInfo[nIndex].m_szDTMF,"");
	strcpy(g_pstChnInfo[nIndex].m_szFlowName,"");
	strcpy(g_pstChnInfo[nIndex].m_szMusicSmsStr,"");
	strcpy(g_pstChnInfo[nIndex].m_szOriCalledNum,"");
	strcpy(g_pstChnInfo[nIndex].m_szRecFile,"");
	strcpy(g_pstChnInfo[nIndex].m_szRecordFile,"");
	strcpy(g_pstChnInfo[nIndex].m_szSql,"");
	strcpy(g_pstChnInfo[nIndex].m_szVoice,"");

	AddSysVarTable(nIndex);
	return 1;
}
FLWPARSER_API int FP_AllowChnsMem(int nChnNums )
{
	if(nChnNums>MAX_FLOW)
		return LP_ERROR_INVALIDPARAM;
	g_pstChnInfo = new CALL[nChnNums];
	return 1;
}
int GetFreeContNo()
{

	int bIsUse = 0;
	int nContNo = -1;
	for(int k = 0 ; k <=MAX_FLOW ;k++ )
	{
			if(g_stCntInfo[k].m_nUse==0)
			{
				nContNo = k;
				break;
			}
	}
	return nContNo;
}
int GetCommand(char *szLine)
{
	char szlog[1000];
	if(szLine==NULL)
	{
		//sprintf(szlog,"GetCommand szLine = NULL Curline =%d ",m_nCurLine);
		//LogMesg(0,szlog,ERROROUTPUT,THIS_FILE, __LINE__);
		return 0;
	}	
	char szOpCode[1000];
	int op;
	strncpy(szOpCode,szLine,5);
	szOpCode[5]='\0';
	op= atoi(szOpCode);
	return op;
}
int ReadFlowFile(int nContNo,const char* szFile)
{
	char szlog[1024];
	FILE * fFlowFile;
	if(szFile==NULL)
		return LP_ERROR_OPENFILE;
	char log [1000];
    char s1[1000]="";
	char s2[1000]="";
	char linetemp[1024];
	fFlowFile=fopen(szFile,"r");
	if(!fFlowFile)
	{
		sprintf(szlog,"读取流程文件失败%s",szFile);
		LogMesg(-1,szlog);
		return LP_ERROR_OPENFILE;
	}
	int i = 0;
	int l=0;
	strcpy(s1,"");
	strcpy(s2,"");

	if(fgets(linetemp,1024,fFlowFile))
	{
		sscanf(linetemp,"%s %s",s1,s2);
		int n = atoi(s1);
		if(n!=10001)
		{
			sprintf(szlog,"读取流程版本失败%s",szFile);
			LogMesg(-1,szlog);
			return LP_ERROR_READFLOWVERSION;
		}
		n=atoi(s2);
		if(n!=100)
		{
			sprintf(szlog,"读取流程版本失败%s",szFile);
			LogMesg(-1,szlog);
			return LP_ERROR_READFLOWVERSION;
		}
	}
	if(fgets(linetemp,1024,fFlowFile))
	{
		//s2中保存为总行数
		sscanf(linetemp,"%s %s",s1,s2);
		int n = atoi(s1);
		if(n!=10002)
			return LP_ERROR_READFLOWVERSION;
		g_stCntInfo[nContNo].m_nMaxLine=atoi(s2);
	}

⌨️ 快捷键说明

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