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

📄 datafuncold.h

📁 170话费催交系统
💻 H
📖 第 1 页 / 共 5 页
字号:
*     名称:int Readdata(int channel)
*     功能:从缓冲区读一条数据
************************************************************************/
int Readdata(int channel)
{
	//清空原数据
	teleinfo[channel].hth[0]='\0';
	teleinfo[channel].num[0]='\0';
	teleinfo[channel].cuijiao[0]='\0';
	teleinfo[channel].qfmonth[0]='\0';
	teleinfo[channel].cjcount=0;
	teleinfo[channel].cjmonth[0]='\0';
	teleinfo[channel].cjyin_flag=1;
	teleinfo[channel].append_count=0;
	//写入新数据
	if(appendcounts > 0){
		strcpy(teleinfo[channel].hth,appendcjdata[readappend].hth);
		strcpy(teleinfo[channel].num,appendcjdata[readappend].num);
		strcpy(teleinfo[channel].cuijiao,appendcjdata[readappend].cuijiao);
		strcpy(teleinfo[channel].qfmonth,appendcjdata[readappend].qfmonth);
		teleinfo[channel].cjcount=appendcjdata[readappend].cjcount;
		strcpy(teleinfo[channel].cjmonth,appendcjdata[readappend].cjmonth);
		teleinfo[channel].cjyin_flag=appendcjdata[readappend].cjyin_flag;
		teleinfo[channel].append_count=appendcjdata[readappend].append_count;	//进辅缓冲区的次数
		
		appendcounts--;
		if(readappend>=APPENDDATA_COUNTS-1)
			readappend=0;
		else
			readappend++;

		return(0);
	}

	if(maincounts > 0){
		strcpy(teleinfo[channel].hth,maincjdata[readmain].hth);
		strcpy(teleinfo[channel].num,maincjdata[readmain].num);
		strcpy(teleinfo[channel].cuijiao,maincjdata[readmain].cuijiao);
		strcpy(teleinfo[channel].qfmonth,maincjdata[readmain].qfmonth);
		teleinfo[channel].cjcount=maincjdata[readmain].cjcount;
		strcpy(teleinfo[channel].cjmonth,maincjdata[readmain].cjmonth);
		teleinfo[channel].cjyin_flag=maincjdata[readmain].cjyin_flag;
		teleinfo[channel].append_count=0;				//进辅缓冲区的次数
		
		maincounts--;
		if(readmain>=MAINDATA_COUNTS-1)
			readmain=0;
		else
			readmain++;

		return(0);
	}
	return(-1);
}

/************************************************************************
*     名称:int Writeappdata(int channel)
*     功能:往辅缓冲区写数据
************************************************************************/
int Writeappdata(int channel)
{
	if(teleinfo[channel].append_count>=cjarg.cb_count) {
		return(-1);
	}
	teleinfo[channel].append_count++;
	if(appendcounts < APPENDDATA_COUNTS){
		//先清空缓冲区上一次的数据
		appendcjdata[writeappend].hth[0]='\0';
		appendcjdata[writeappend].num[0]='\0';
		appendcjdata[writeappend].cuijiao[0]='\0';
		appendcjdata[writeappend].qfmonth[0]='\0';
		appendcjdata[writeappend].cjcount=0;
		appendcjdata[writeappend].cjmonth[0]='\0';
		appendcjdata[writeappend].cjyin_flag=1;
		appendcjdata[writeappend].append_count=0;
		//写入新数据
		strcpy(appendcjdata[writeappend].hth,teleinfo[channel].hth);
		strcpy(appendcjdata[writeappend].num,teleinfo[channel].num);
		strcpy(appendcjdata[writeappend].cuijiao,teleinfo[channel].cuijiao);
		strcpy(appendcjdata[writeappend].qfmonth,teleinfo[channel].qfmonth);
		appendcjdata[writeappend].cjcount=teleinfo[channel].cjcount;
		strcpy(appendcjdata[writeappend].cjmonth,teleinfo[channel].cjmonth);
		appendcjdata[writeappend].cjyin_flag=teleinfo[channel].cjyin_flag;
		appendcjdata[writeappend].append_count=teleinfo[channel].append_count;	//进辅缓冲区的次数

		appendcounts++;
		if(writeappend>=APPENDDATA_COUNTS-1)
			writeappend=0;
		else
			writeappend++;
	}
	return(0);
}

/*********************************************
*     名称:int Index_sz(int channel)
*     功能:索引语音数组
*********************************************/
int Index_sz(int channel)
{
	int count;
	int countn;
	DX_IOTT *iott_qs;

	count=0;
	switch(teleinfo[channel].cjyin_flag) {
	case 1:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 2: 
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOB_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOB_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[2].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 3:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOC_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOC_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[3].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	default:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	}
	count++;

	iott_qs=dxinfo[channel].iott_cjvalue+count;
	countn=Index_value( teleinfo[channel].cuijiao, iott_qs, 0, channel);
	count=count+countn;
	dxinfo[channel].iott_cjvalue[count-1].io_nextp = &dxinfo[channel].iott_cjvalue[count];
	dxinfo[channel].iott_cjvalue[count-1].io_type = IO_DEV|IO_LINK;

	switch(teleinfo[channel].cjyin_flag) {
	case 1:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 2:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERB_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERB_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[2].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 3:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERC_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERC_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[3].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	default:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	}
	return(0);
}

/**************************************************************************************
*		int Index_time(char *sz_time, DX_IOTT *iott_time,int filenum,int channum)
*	函数说明: 索引时间字串,并将索引后的语音内容填入 *iott_time,返回语音串的长度
*	参数:  DX_IOTT *iott_time 索引数组的指针
*			int filenum   传递时间语音文件在数组中的位置
*			int channum   指定操作的通道
*	年月日 *sz_time
**************************************************************************************/

int Index_time(char *sz_time, DX_IOTT *iott_time,int filenum,int channum)
{
		int count;
		int count_a;

		for(count=0;count<4;count++) {
			iott_time[count].io_offset = numberfilewz[sz_time[count]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[count]-48].length;
		}

		iott_time[count].io_offset = YEAR_OFFSET;
		iott_time[count].io_length = YEAR_LENGTH;
		count++;

		if(sz_time[4]==48) {
			iott_time[count].io_offset = numberfilewz[sz_time[5]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[5]-48].length;
		}
	        else
        	{
			iott_time[count].io_offset = TEN_OFFSET;
			iott_time[count].io_length = TEN_LENGTH; 
			count++;
			iott_time[count].io_offset = numberfilewz[sz_time[5]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[5]-48].length;
		}
		count++;
		
		iott_time[count].io_offset = MONTH_OFFSET;
		iott_time[count].io_length = MONTH_LENGTH;
		count++;
		
		if(sz_time[6]==48) {
			iott_time[count].io_offset = numberfilewz[sz_time[7]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[7]-48].length;
		}
		else if(sz_time[6]==49) {
			iott_time[count].io_offset = TEN_OFFSET;
			iott_time[count].io_length = TEN_LENGTH; 
			count++;
			iott_time[count].io_offset = numberfilewz[sz_time[7]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[7]-48].length;
		}
		else
		{
			iott_time[count].io_offset = numberfilewz[sz_time[6]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[6]-48].length;
			count++;
			iott_time[count].io_offset = TEN_OFFSET;
			iott_time[count].io_length = TEN_LENGTH; 
			count++;
			iott_time[count].io_offset = numberfilewz[sz_time[7]-48].offset;
			iott_time[count].io_length = numberfilewz[sz_time[7]-48].length;
		}
		count++;
		iott_time[count].io_offset = DAY_OFFSET;
		iott_time[count].io_length = DAY_LENGTH;

		for(count_a=0;count_a<count;count_a++) {
			iott_time[count_a].io_type = IO_DEV|IO_LINK;
			iott_time[count_a].io_nextp = &iott_time[count_a+1];
			iott_time[count_a].io_fhandle=szfile[filenum].filehandle;
			iott_time[count_a].io_bufp = 0;
		}

		iott_time[count].io_type = IO_DEV|IO_EOT;
		iott_time[count].io_nextp = NULL;
		iott_time[count].io_fhandle=szfile[filenum].filehandle;
		iott_time[count].io_bufp = 0;

		count++;
		return(count);
}

/**************************************************************************************
*		Index_value(char *sz_value,DX_IOTT *iott_value,int filenum,int channum)
*	函数说明: 索引金额字串,并将索引后的语音内容填入 *iott_value,返回语音串的长度
*	参数:  DX_IOTT *iott_value 索引数组的指针
*			int filenum   传递时间语音文件在数组中的位置
*			int channum   指定操作的通道
*	金额 *sz_value
**************************************************************************************/
int Index_value(char *sz_value,DX_IOTT *iott_value,int filenum,int channum)
{
	int count_tmp;
	int length_tmp;
	int count_position;		//金额字串索引到的当前位置
	int count;				//语音串的计数器
	int account;			//暂存金额字串中各位的值
	int tmp_allzero;		//后面的值全为零的标志
	int ling_flag;			//是否播'零'语音的标志
	int zero_yuan;			//元部分为0的标志
	int zero_jiao;			//角为0的标志
	int length;				//金额字串的长度
	int point;				//小数点在字串中所在的位置
	int length_integer;		//整数部分的长度
	int length_decimal;		//小数点后的长度

	length=0;
	while(sz_value[length]!=0)
		length++;

	for(point=1;point<=length;point++) {
		if(sz_value[point-1]==46)
			break;
	}

	if(point<=length) {
		length_integer=point-1;
		length_decimal=length-point;
		if(length_decimal>2) {
			length_decimal=2;
			length=point+2;
		}
	}
	else
	{
		length_integer=length;
		length_decimal=0;
	}

	count_position=0;
	count=0;
	ling_flag=1;

	while((count_position<length_integer)&&(count<=JE_LENGTH)) {
		account=sz_value[count_position];
		if(((account == 49)&&(count_position == 0)&&(length_integer%4 == 2))||
				(( account == 48)&&( ling_flag == 1))){
			iott_value[count].io_offset = 0;
			iott_value[count].io_length = 0;
		}
		else
		{
			iott_value[count].io_offset = numberfilewz[account-48].offset;
			iott_value[count].io_length = numberfilewz[account-48].length;
			if( account== 48)
				ling_flag=1;
			else
				ling_flag=0;
		}

		length_tmp=(length_integer-count_position-1)%4+1; 
		count_tmp=1;
		while(count_tmp<length_tmp) {
			if((sz_value[count_position+count_tmp]>48)&&(sz_value[count_position+count_tmp]<=57)) {
				tmp_allzero=0;
				break;
			}
			count_tmp++;
			tmp_allzero=1;
		}
		if((tmp_allzero==1)&&(length_tmp>1)) {
			ling_flag=1;
		}

		if(length_tmp == 1) {
			for(count_tmp=count_position+1;count_tmp<length_integer;count_tmp++) {
				if(( sz_value[count_tmp]>48)&&(sz_value[count_tmp]<=57)) {
					tmp_allzero=0;
					break;
				}
				tmp_allzero=1;
			}
			if(tmp_allzero==1) {
				ling_flag=1;
			}
			else
			{
				ling_flag=0;
			}
		}
		count++;

		switch ((length_integer-count_position)%4) {
		case 0:
			if((account<=48)||(account>57)){
				iott_value[count].io_offset = 0;
				iott_value[count].io_length = 0;
			}
			else
			{
				iott_value[count].io_offset = THOUSAND_OFFSET;
				iott_value[count].io_length = THOUSAND_LENGTH;
			}
			break;
		case 3:
			if((account<=48)||(account>57)){
				iott_value[count].io_offset = 0;
				iott_value[count].io_length = 0;
			}
			else
			{
				iott_value[count].io_offset = HUNDRED_OFFSET;
				iott_value[count].io_length = HUNDRED_LENGTH;
			}
			break;
		case 2: 
			if((account<=48)||(account>57)){
				iott_value[count].io_offset = 0;
				iott_value[count].io_length = 0;
			}
			else
			{
				iott_value[count].io_offset = TEN_OFFSET;
				iott_value[count].io_length = TEN_LENGTH;
			}
			break;
		case 1:
			if((length_integer-count_position) > 8) {
				iott_value[count].io_offset = YI_OFFSET;
				iott_value[count].io_length = YI_LENGTH;
			}
			else if((length_integer-count_position) > 4) {
				iott_value[count].io_offset = MYRIAD_OFFSET;
				iott_value[count].io_length = MYRIAD_LENGTH;
			}
			else
			{
				if(( length_integer == 1)&&( account == 48)) {
					zero_yuan = 1;
					iott_value[count].io_offset = 0;
					iott_value[count].io_length = 0;
				}
				else
				{
					zero_yuan=0;
					iott_value[count].io_offset = YUAN_OFFSET;
					iott_value[count].io_length = YUAN_LENGTH;
				}
			}
			break;
		}
		count++;
		count_position++;
	}

	count_position=point;
	ling_flag=1;

	while ((count_position<length)&&(count<=JE_LENGTH)) {
		account=sz_value[count_position];
		if((account==48)&&(count_position+1<length)) {
			if((sz_value[count_position+1]>48)&&(sz_value[count_position+1]<=57)&&(zero_yuan==0)) {
				ling_flag=0;
			}
			else
				ling_flag=1;
		}
		if((account==48)&&(ling_flag==1)) {
			iott_value[count].io_offset = 0;
			iott_value[count].io_length = 0;
		}
		else
		{
			iott_value[count].io_offset = numberfilewz[account-48].offset;

⌨️ 快捷键说明

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