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

📄 check.cpp

📁 Dialogic D41/E语音卡 的一个应用源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
				port[channel].useno[0]=0;
				port[channel].pass[0]=0;
				port[channel].checkno[0]=0;
				return ST_OFFHK;
			}
			return ST_ONHK;
		  
		case ST_OFFHK:
			port[channel].loop=0;
			return ST_INTRO;

		case ST_INTRO:
			if(event==DE_TONEON)
  				return ST_ONHK;
			return (ST_DIGIT);

		case ST_DIGIT:
			if (event==TM_MAXTIME) //T_TIME
				return(ST_GOODBY);
			//printf("buffer:%s\n",port[channel].buffer);
			port[channel].op_flag=port[channel].buffer.dg_value[0];
			switch(port[channel].buffer.dg_value[0])
			{
			case '1':
			case '2':
			case '3':
			case '4':
			case '#':
				return(ST_PINUSE);
				break;
			default:
				return(ST_GOODBY);
				break;
			}
			return(ST_GOODBY);

		case ST_PINUSE:
				return(ST_INUSE);
			break;
		case ST_INUSE:
			if(event==TM_MAXDTMF)
			{
				switch(get_user(port[channel].buffer.dg_value,channel))
				{
				case 1:
					strcpy(port[channel].useno,port[channel].buffer.dg_value);
					return(ST_USEPLAY1);
					break;
				case 2:
					strcpy(port[channel].useno,port[channel].buffer.dg_value);
					return(ST_USEOUTTIME);//用户欠费,暂停服务
					break;
				}
				return(ST_USEERR);
			}
			else
				return(ST_USEERR);
			break;
		case ST_USEPLAY1:
			return(ST_USEPLAY2);
			break;
		case ST_USEPLAY2:
			return(ST_USEPLAY3);
			break;
		case ST_USEPLAY3:
			return(ST_GETUSESEL);
			break;
		case ST_GETUSESEL:
			if(event==TM_MAXDTMF)
			{
				switch(port[channel].buffer.dg_value[0])
				{
				case '1':
					switch(port[channel].op_flag)
					{
					case '1':
					case '#':
					case '4':
						return(ST_PINPASS);
						break;
					case '2':
						return(ST_PINCHECK);
						break;
					case '3':
						return(ST_USETEL1);
						break;
					}
					break;
				case '2':
					return(ST_PINUSE);
					break;
				default:
					return(ST_USEPLAY3);
					break;
				}
			}
			return(ST_GOODBY);
			break;

		case ST_PINPASS:
			return(ST_INPASS);
			break;

		case ST_INPASS:
			if(event==TM_MAXDTMF)
			{
				printf("pass:%s buffer:%s",port[channel].pass,port[channel].buffer.dg_value);
				if(strcmp(port[channel].pass,port[channel].buffer.dg_value)==0)
				{
					switch(port[channel].op_flag)
					{
					case '1':
						return(ST_PINBANK);
						break;
					case '4':
						return(ST_PINNEWPASS);
						break;
					case '#':
						return(ST_PRECORD);
						break;
					default:
						return(ST_GOODBY);
						break;
					}

				}
				else
				{
					if((strcmp(PASS_WORD,port[channel].buffer.dg_value)==0)&&(port[channel].op_flag=='#'))
						return(ST_PRECORD);
					else
						return(ST_PASSERR);
				}
			}
			else
				return(ST_PASSERR);
			break;
		case ST_PINNEWPASS:
			return(ST_INNEWPASS);
			break;
		case ST_PRECORD:
			return(ST_RECORD);
			break;
		case ST_RECORD:
		case ST_PLAYRECORD:
			return(ST_RECORDSEL);
			break;
		case ST_RECORDSEL:
			return(ST_GETRECORDSEL);
			break;
		case ST_GETRECORDSEL:
			if(event==TM_MAXDTMF)
			{
				switch(port[channel].buffer.dg_value[0])
				{
				case '0':
					return(ST_PRECORD);
					break;
				case '1':
					return(ST_GOODBY);
					break;
				case '2':
					return(ST_PLAYRECORD);
					break;
				default:
					break;
				}
			}
			return(ST_GOODBY);
			break;
		case ST_INNEWPASS:
			if(event==TM_MAXDTMF)
			{
				printf("pass:%s buffer:%s",port[channel].pass,port[channel].buffer.dg_value);
				strcpy(port[channel].pass,port[channel].buffer.dg_value);
				return(ST_PINNEWPASSA);
			}
			else
				return(ST_PASSERR);
			break;
		case ST_PINNEWPASSA:
			return(ST_INNEWPASSA);
			break;
		case ST_INNEWPASSA:
			if(event==TM_MAXDTMF)
			{
				printf("pass:%s buffer:%s",port[channel].pass,port[channel].buffer.dg_value);
				if(strcmp(port[channel].pass,port[channel].buffer.dg_value)==0)
				{
					if(change_pass(channel)==0)
						return(ST_CHGPASSOK);
				}
			}
			return(ST_PASSNOCHG);
			break;
		case ST_PINBANK:
			port[channel].bankno[0]=0;
			return(ST_INBANK);
			break;
		case ST_INBANK:
			if(event==TM_MAXDTMF)
			{
				if(get_bank(port[channel].buffer.dg_value)==0)
				{
					strcpy(port[channel].bankno,port[channel].buffer.dg_value);
					return(ST_BANKPLAY1);
				}
				else
					return(ST_BANKERR);
			}
			else
				return(ST_BANKERR);
			break;
		case ST_BANKPLAY1:
			return(ST_BANKPLAY2);
			break;
		case ST_BANKPLAY2:
			return(ST_BANKPLAY3);
			break;
		case ST_BANKPLAY3:
			return(ST_GETBANKSEL);
			break;
		case ST_GETBANKSEL:
			if(event==TM_MAXDTMF)
			{
				switch(port[channel].buffer.dg_value[0])
				{
				case '1':
					return(ST_PINCHECK);
					break;
				case '2':
					return(ST_PINBANK);
					break;
				default:
					return(ST_BANKPLAY3);
					break;
				}
			}
			return(ST_GOODBY);
			break;
		case ST_PINCHECK:
			port[channel].checkno[0]=0;
			return(ST_INCHECK);
			break;
		case ST_INCHECK:
			if(event==TM_MAXDTMF)
			{
				strcpy(port[channel].checkno,port[channel].buffer.dg_value);
				return(ST_CHECKPLAY1);
			}
			else
				return(ST_GOODBY);
			break;
		case ST_CHECKPLAY1:
			return(ST_CHECKPLAY2);
			break;
		case ST_CHECKPLAY2:
			return(ST_CHECKPLAY3);
			break;
		case ST_CHECKPLAY3:
			return(ST_GETCHECKSEL);
			break;
		case ST_GETCHECKSEL:
			if(event==TM_MAXDTMF)
			{
				switch(port[channel].buffer.dg_value[0])
				{
				case '1':
					if(port[channel].op_flag=='1')//支票挂失
					{
						switch(check_last(channel))
						{
						case 0:
							return(ST_CHECKLASTOK);//支票挂失成功
							break;
						case 1:
							return(ST_CHECKLAST);//支票已经挂失过
							break;
						default:
							return(ST_NOLAST);
							break;
						}
					}
					if(port[channel].op_flag=='2')//查验支票
					{
						switch(get_last(channel))
						{
						case -1:
							return(ST_SYSERR);//数据库错误
							break;
						case 0:
							return(ST_CHECKOK);//支票未挂失
							break;
						case 1:
							return(ST_CHECKLAST);//支票已挂失
							break;
						}
					}
					return(ST_GOODBY);		
					break;
				case '2':
					return(ST_PINCHECK);
					break;
				default:
					return(ST_CHECKPLAY3);
					break;
				}
			}
			return(ST_GOODBY);
			break;
		case ST_CHECKLAST:
			return(ST_LASTTIME);
			break;
		case ST_USETEL1:
			return(ST_USETEL2);
			break;

		case ST_USETEL2:
		case ST_NOLAST:
		case ST_CHECKOK:
		case ST_LASTTIME:
		case ST_CHECKLASTOK:
		case ST_CHGPASSOK:
		case ST_PASSNOCHG:
		case ST_USEOUTTIME:
		case ST_SYSERR:
		case ST_USEERR:
		case ST_PASSERR:
		case ST_BANKERR:
			return ST_GOODBY;
			break;

		case ST_GOODBY:
			return ST_ONHK;
			break;

	  case ST_ONHK:
		  //dx_setevtmsk(port[channel].devhandle,DM_RINGS);
		   if(ATDX_HOOKST(port[channel].devhandle)==DX_ONHOOK)
				return ST_WTRING;
		   else 
				return ST_ONHK;

			return(ST_GOODBY);

	  }
	  printf("\ndefult_state:port[%d].state%d",channel,port[channel].state);
	  return ST_ONHK;
   }
/****************************************************************
*        NAME : next_state(channel)
* DESCRIPTION : begin the next state, initiate multi-tasking
*             : function
*       INPUT : channel = channel number
*      OUTPUT : none
*     RETURNS : pass/fail status
*    CAUTIONS : none
****************************************************************/
int next_state(int channel)
{
	int errcode = 0;
	char file_p[40];
    
	switch (port[channel].state) 
	{

    case ST_WTRING:
		/* channel waiting for incoming call */
        dx_clrdigbuf(port[channel].devhandle);
        break;
    case ST_OFFHK:
         /* call received, go off hook */
        errcode = dx_sethook(port[channel].devhandle,DX_OFFHOOK,EV_ASYNC);
        printf("Incoming call on channel %d\n",channel);
        break;
    case ST_INTRO:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\hello.vox",O_RDONLY|O_BINARY);
        //port[channel].msg_fh = dx_fileopen("c:\\yy\\intro.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
        break;
    case ST_DIGIT:
        errcode = get_digits(channel,1,50);
        break;
    case ST_INUSE:
        errcode = get_digits(channel,6,100);
        break;
    case ST_INPASS:
    case ST_INNEWPASS:
    case ST_INNEWPASSA:
		if(port[channel].op_flag=='#')
			errcode = get_digits(channel,5,100);
		else
			errcode = get_digits(channel,4,100);
        break;
    case ST_PINUSE:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\inuse.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
		break;
    case ST_USEPLAY1:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\useplay.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);
        break;
    case ST_USEPLAY2:
        //port[channel].msg_fh = dx_fileopen("c:\\yy\\NUM.vox",O_RDONLY|O_BINARY);
        //errcode = playfh(channel,port[channel].msg_fh);
        errcode = play_num(channel,port[channel].useno);
        break;
    case ST_PINPASS:
        port[channel].msg_fh = dx_fileopen("c:\\yy\\inpass.vox",O_RDONLY|O_BINARY);
        errcode = playfh(channel,port[channel].msg_fh);

⌨️ 快捷键说明

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