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

📄 vsinterpreter.h

📁 基于dialogic语音卡的IVR系统源代码
💻 H
字号:
// VSInterpreter.h: interface for the CVSInterpreter class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_VSINTERPRETER_H__4AE7B0F5_2D35_11D3_929C_0080C8E20453__INCLUDED_)
#define AFX_VSINTERPRETER_H__4AE7B0F5_2D35_11D3_929C_0080C8E20453__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//#include "ServiceRequestQueue.h"
//#include "ServiceReplyQueue.h"
#include "ServiceDataQueue.h"
#include "ResultSet.h"
#include "SourceMonitor.h"
#include "ServiceBroker.h"

#include "Setup.h"

extern void startConsoleWin(int width, int height, char* fname);
int wprintf(char *fmt, ...);
int wprintf_err(char *fmt, ...);
int wprintf_err1(char *fmt, ...);
int wprintf_err2(struct CurrentState *pcurrentState, char *fmt, ...);
UINT VSInterpreterThread(LPVOID pParam);

struct VSFileBuf
{
	char aszVSFileName[MAX_PATH];
	char *szFileBuf;
	int iFileBufLen;
};

struct VSFileBufList
{
	int iCount;
	struct VSFileBuf *vsFileBuf;
};

class CVSInterpreter  
{
public:
	int CallTransfer(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallSendFsk(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallRecvFsk(CurrentState *pcurrentState, VSInstruction *pvsi);
	static int CreateDirectoryEn(char *szFullDir);
//	int GetPrivateProfileString(char *szAppName, char *szKeyName, char *szDefault, char *szReturnedString, DWORD nSize, char *szFileName);
	int GetFullPath2(char *szOldPath, int iChannleNo, char *szFullPath);
	int GetFullPath(char *szOldPath, struct CurrentState *pcurrentState, char *szFullPath);
	int SetInstructionFile(int iChannelNo, char *szInstructionFile);
	int SyncVScriptFile(int iChannelNo);
	int ProcessQueryRequest(struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int CallAnswerRequest(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallWtRequest(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallTif(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallASR(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallOnHook(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallOffHook(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallDial(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallRecord(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallRcvFax(CurrentState *pcurrentState, VSInstruction *pvsi);
	int CallSendFax(struct CurrentState *pcurrentState, struct VSInstruction *pvsi, int iSendType);
	int FindTheEndOfParam(char *szStatement, int *piOffsetOfTheEnd);
	int AbstractParam(char *szParams, int iIndex, char *szOut, char cSeperatorChar);
	int CallPlayInfo(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallGetInfo(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int SourceMonitor_LoadFile(struct CurrentState *pcurrentState);
	int SourceMonitor_SelectLine(char *szIID, int iKeyIndex, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetFunctionType(char *szFunction);
	char * FindFirstOperator(char *szStatement);
	int CallInternalFunction(char *szFunction, void *pOutput, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int ReadLineFromFile(FILE *file, char **ppBuffer, int *piSize);
	struct VoiceList * StringToVoiceList(char *szVoiceList, struct CurrentState *pcurrentState);
	int GetKeyStringType(char *szKeyString, int *piType);
	int CompileInstructFile(char *szSourceInstructionFileName);
	int AddVoiceList(struct VoiceList *pvoiceList, char *szVoiceMember, int iMemberType);
	int FreeList(struct VoiceList *pvoiceList);
	int DoDO(char *szStatement, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	BOOL IfHaveDO(char *szStatement);
	int CalculateStatement_Float(char *szStatement, float *pfResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int CalculateStatement_String(char *szStatement, char *szResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int CalculateStatement(char *szStatement, int *piResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int ParseIFStatement(char *szStatement, char *szNextIID, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int Calculate(char *szStatement, int *piResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int FindTheEndOfStatementUnit2(char *szStatement, int *piOffsetOfTheEnd);
	int FindTheEndOfStatementUnit(char *szStatement, int *piOffsetOfTheEnd);
	int FindTheEndOfIFStatement(char *szStatement, int *piOffsetOfTheEnd);
	int FindTheOtherRightQuotation(char *szStatement, char cQuotationType, int iOffsetOfTheLeftQuotation, int *piOffsetOfTheOtherRightQuotation);
	int FindTheOtherRightBracket(char *szStatement, char cBracketType, int iOffsetOfTheLeftBracket, int *piOffsetOfTheOtherRightBracket);
	int FindTheOtherRightBracket(char *szStatement, int iOffsetOfTheLeftBracket, int *piOffsetOfTheOtherRightBracket);
	int FindTheOtherRightSymbol(char *szInput, int iOffsetOfTheLeftSymbol, int *piOffsetOfTheOtherRightSymbol);
	BOOL IsInTheSymbolTwin(char *szInput, int iOffset, char cLeftSymbolType, int *piOffsetOfTheOtherSymbol, BOOL *pbResult);
	int GetValueOfBrackets_Float(char *szStatement, float *pfResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetValueOfBrackets(char *szStatement, int *piResult, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int DoSET(char *szSETStatement, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int DoSET_Simple(char *szVariableName, int iIndex, struct CurrentState *pcurrenState, struct ParamList *preplyParamList);
	int ProcessSpecialServiceReply(int iSpecialServiceNo, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int ProcessServiceReply(struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetGOTO(char *szStatement, char *szIID, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetContentInBracket(char *szStatement, int iOffsetOfTheLeftBracket, char *szOut);
	int ParseNextInstruction(struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int Run();
	int SetGlobalValue_Integer(char *szGlobal, int iValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetGlobalValue_Integer(char *szGlobal, int *piValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int SetGlobalValue_String(char *szGlobal, char *szValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetGlobalValue_String(char *szGlobal, char *szValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int SetGlobalValue_Float(char *szGlobal, float Value, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetGlobalValue_Float(char *szGlobal, float *pfValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetStringValue(char *szString, void *pValue, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int GetStringType(char *szString, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	char *FindCompareOperator(char *szStatement, int *piType, int *pLength);
	char *FindLogicalOperator(char *szStatement, int *piType);
	BOOL IsConditionTrue_String(char *szCondition, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	BOOL IsConditionTrue_Float(char *szCondition, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	BOOL IsConditionTrue(char *szCondition, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	BOOL IsIFTrue(char *szStatement, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	BOOL IsSETStatement(char *szStatement);
	BOOL IsIFStatement(char *szStatement, int *piIFType);
	int IsSingleName(char *szStatement);
	int ParseVoiceList(struct VoiceList *pvl, int iIndex, char *szVoiceFile);
	int GetParamType(char *szParam, int *piType, int *piNumberType, struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int AbstractStatementUnit(char *szStatement, int iIndex, char *szOut, char cSeperatorChar);
	int AbstractStatementUnit2(char *szStatement, int iIndex, char *szOut, char cSeperatorChar);
	int AbstractStatementUnit3(char *szStatement, int iIndex, char *szOut, char cSeperatorChar);
	static int AbstractData(char *szData, int nIndex, char *szOut, char cSeperatorChar);
	int GetStringBeforeChar(char *szInput, char *szOutput, int iOutputLen, char cSpecifiedChar);
	int FormatStringForAppService(int iServiceNo, char *szInput, char *szOutput);
	int CallService(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallReturn(struct CurrentState *pcurrentState, struct ParamList *preplyParamList);
	int CallJump(struct CurrentState *pcurrentState, struct VSInstruction *pvsi, struct ParamList *preplyParamList);
	int CallSleep(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallLog(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallLANG(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallGetKey(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int CallPlay(struct CurrentState *pcurrentState, struct VSInstruction *pvsi, int iPlayType);
	int CallWtring(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int DoAction_Internal(struct CurrentState *pcurrentState, struct VSInstruction *pvsi, struct ParamList *preplyParamList);
	int DoAction(struct CurrentState *pcurrentState, struct VSInstruction *pvsi, struct ParamList *preplyParamList);
	int GetString(char *szInstructionFileName, char *szSectionName, char *szKeyName, char *szReturnedString, int iSize);
	int GetSection3(char *szInstructionFileName, char *szSectionName, char *szSectionString, int nSize);
	int GetSection2(char *szInstructionFileName, char *szSectionName, char *szSectionString, int nSize);
	int GetSection(char *szInstructionFileName, char *szSectionName, char *szSectionString, int nSize);
	int GetFirstIntruction(struct CurrentState *pcurrentState, struct VSInstruction *pvsi);
	int GetInstruction(struct CurrentState *pcurrentState, char *IID, char *LastIID, struct VSInstruction *pvsi);
	int RecoverPreviousCurrentState(struct CurrentState *pcurrentState, char *szReturnIID);
	int FreeCurrentState(struct CurrentState *pcurrentState);
	int ClearCurrentState(struct CurrentState *pcurrentState);
	int AddUniversal_Float(struct CurrentState *pcurrentState, char *szName, float fValue, BOOL bOverride = TRUE);
	int AddUniversal_String(struct CurrentState *pcurrentState, char *szName, char *szValue, BOOL bOverride = TRUE);
	int AddUniversal_Integer(struct CurrentState *pcurrentState, char *szName, int iValue, BOOL bOverride = TRUE);
	int AddGlobal_Integer(struct CurrentState *pcurrentState, char *szName, int iValue);
	int AddGlobal_String(struct CurrentState *pcurrentState, char *szName, char *szValue);
	int AddGlobal_Float(struct CurrentState *pcurrentState, char *szName, float fValue);
	int InitializeParamList(struct CurrentState *pcurrentState);
	int InitializeUniversalVariable(struct CurrentState *pcurrentState, BOOL bOverride = TRUE);
	int InitializeGlobal_Integer(struct CurrentState *pcurrentState);
	int InitializeGlobal_String(struct CurrentState *pcurrentState);
	int InitializeGlobal_Float(struct CurrentState *pcurrentState);
	int LoadVSFileToBuffer(int iChannelNo);
	int LoadVSFileToBuffer_Refresh(int iChannelNo);
	int InitializeChannelDataStructure();
	int Initialize();
	int Create(int iChannelCount);
	//ldy add 2000/12/4
	int ISValidNumber(char *szNumber,char *szType);
//	int DIV(char *szKYTotal,char *szBuyValue);
	int DIV(float m_iBuyValueszKYTotal,float m_iBuyValue);
	//add by lj
	int AccessDb(CurrentState *pcurrentState, VSInstruction *pvsi);
	int AbstractData2(char *szData, int nIndex, char *szOut, char cSeperatorChar);
	int IsValidSymbol(char *pDest, char c);
	int FindCharNum(char* dest, char c);
	int FindAllChar(char *dest, char c, int& i);
	//end add

//	char * m_szInstructionFile;
//	char * m_szSourceInstructionFile;
//	char * m_szTempInstructionFile;

	struct VSFileBufList m_vsFileBufList;	//预先读入的所有脚本文件的内容缓冲链表,取指令时就从这些缓冲中取,而不调用GETPRIVATEPROFILESTIRNG,以提高性能

	struct CurrentState *m_pcurrentState;
	struct ParamList m_resultList;	//内部指令的执行结果列表,因为内部指令是同步函数,所以不需要为每个通道开辟一个resultlist
	struct ParamList *m_preplyParamList;	
		//用于保存这次从应答队列中取出的应答指针,给后面的处理函数
		//(处理应答函数,判断后续指令函数,执行下一步指令函数)使用,
		//然后又被下一个应答指针覆盖
	HANDLE m_hEvent_AddReply;
	CSourceMonitor *m_psourceMonitor;
	HWND m_hwndSourceMonitor;
	DWORD m_dwGDIThreadID;

	int m_iChannelCount;
	int m_iIVRServiceType;	//IVR服务的类型号,需要在发送语音请求的时候用到,在SETUP.INI中得到
	
	char m_aszTempPath[100];
	char m_aszSysVocPath[100];

	char m_aszIID[100];	//当前的节点号,以便在任何函数中都可根据IID调试

	//IVR的监控数据
	int m_iCountOfTurnOnOfTotal_In;			//总接通数(呼入)
	int m_iCountOfTurnOnOfTotal_Out;		//总接通数(呼出)

	CVSInterpreter();
	virtual ~CVSInterpreter();
};

//解释器自带线程的输入参数
struct GDIThreadParam
{
	CVSInterpreter *pvsInterpreter;
//	CSourceMonitor *psourceMonitor;
	char aszInstructionFileName[100];
	int iChannelCount;						//通道总数
	BOOL bGDIThreadRunning;
};

//解释器线程的输入参数
struct VSInterpreterThreadParam
{
	char aszInstructionFileName[100];
	int iChannelCount;
	char aszControlThreadName[100];	//用于控制线程的结束的EVENT名
	char aszTempPath[100];
};

#endif // !defined(AFX_VSINTERPRETER_H__4AE7B0F5_2D35_11D3_929C_0080C8E20453__INCLUDED_)

⌨️ 快捷键说明

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