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

📄 carddbi.c

📁 国家ASIC工程中心使用的嵌入式操作系统
💻 C
📖 第 1 页 / 共 3 页
字号:
	head = CardTransDatabsFormat(findlist->head->data,findlist->head->index);
	head->prev =NULL;
	head->next= NULL;

	pointer = head;

	for(count=1;count<(findlist->num);count++)
	{
		tmprecord = (findlist->head)+count;
		newptr = CardTransDatabsFormat(tmprecord->data,tmprecord->index);
		newptr->prev = pointer;
		newptr->next = NULL;
		pointer->next = newptr;
		pointer = newptr;
	}
	DelOldSearchList(findlist);//释放获得的数据块
	return head;	

   
}




STATUS  CardDelRecord(CALLCARD*thisptr)  //定义变量,参数
{
    //输入的是保存记录的ID号
    //根据ID号查询数据库
    //并且删除此记录
    //如果删除记录成功则返回ASIX_OK否则返回ASIX_ERROR
    U32 delst;
    delst = LocalDelRecord(cardlacb, thisptr->ID);
    if(delst == DB_ERROR)
    	 return ASIX_ERROR;
    else 
    	 return ASIX_OK;
}

void GetCardRecordItemNum(CALLCARD*recordinf,CARDBUFRECORDINF * sourceinf)
{
	U8 count;
	U8 countctel=0,countcmob=0,countcbp=0,countcfax=0,countcunit=0,countcemail=0,countcaddress=0;
	U8 countcQQ=0,countchabit=0,countcpostalcode=0;
	for (count =0;count<(MAXTELNUM);count++)
	{
	   if((*(recordinf->tel[count]))!= 0)
		{
			countctel++;
		}
	}
	sourceinf->ctel = countctel;
	for (count =0;count<(MAXMOBNUM);count++)
	{
	    if((*(recordinf->mobile[count]))!= 0)//modified on 0920 因为是指向内存区域,但是不为空
	    {
	      	  countcmob++;
	    }
	}
	sourceinf->cmob = countcmob;
	for (count =0;count<(MAXBPNUM);count++)
	{
		if((*(recordinf->bp[count]))!= 0)
		{
			countcbp++;
		}

	}
	 sourceinf->cbp = countcbp;
	 for (count =0;count<(MAXFAX);count++)
	{
	   if((*(recordinf->fax[count]))!= 0)
	   {
	      	 countcfax++;
	    }
	}
	sourceinf->cfax = countcfax;
	for (count =0;count<(MAXUNIT);count++)
	{
		if((*(recordinf->unit[count]))!= 0)
		{
			 countcunit++;
		}
	}
	sourceinf->cunit = countcunit;
	for (count =0;count<(MAXEMAIL);count++)
	{
		if((*(recordinf->email[count]))!= 0)
		{
			 countcemail++;
		}
	}
	 sourceinf->cemail = countcemail;
	for (count =0;count<(MAXADDRESS);count++)
	{
		if((*(recordinf->address[count]))!= 0)
		{
			 countcaddress++;
		}
	}
	sourceinf->caddress= countcaddress;
	for (count =0;count<(MAXQQ);count++)
	{
		if((*(recordinf->QQ[count]))!= 0)
		{
			 countcQQ++;
		}
	}
	 sourceinf->cQQ= countcQQ;
	 for (count =0;count<(MAXHABIT);count++)
	{
	   if((*(recordinf->habbit[count]))!= 0)
	   {
	      	 countchabit++;
	    }
	}
	 sourceinf->chabit= countchabit;
	for (count =0;count<(MAXPOSTALCODE);count++)
	{
		if((*(recordinf->postalcode[count]))!= 0)
		{
			 countcpostalcode++;
		}
	}
	 sourceinf->cpostalcode = countcpostalcode;
}








//比较暂时存储的数据与原始数据比较,如果不同,则表示
void CardCompareModSrc(CALLCARD *thisptr,CARDBUFRECORDINF * inf,U8 * ismodfptr)
{
	U8 count;
	U8 compare;
	U8 pos;
	CARDBUFRECORDINF sourcebuf;
	CARDBUFRECORDINF * sourceinf = &sourcebuf;

	//如果项目的数目不一样,也是认为不同

	GetCardRecordItemNum(thisptr,sourceinf);
	/*如果有其中的记录的项目数不同,则认为是需要保存*/
	if((inf->ctel !=sourceinf->ctel)||(inf->cmob !=sourceinf->cmob)||(inf->cbp !=sourceinf->cbp)
		||(inf->cfax !=sourceinf->cfax)||(inf->cunit !=sourceinf->cunit)||(inf->cemail !=sourceinf->cemail)
		||(inf->caddress !=sourceinf->caddress)||(inf->cQQ!=sourceinf->cQQ)
		||(inf->chabit!=sourceinf->chabit)||(inf->cpostalcode!=sourceinf->cpostalcode))
	{
		*ismodfptr = 1;
		return ;
	}

	//比较姓名
	compare = strcmp(thisptr->name,inf->recordinf[0]);
	if(compare != 0)
	{
	   *ismodfptr = 1;
	   return ;
	}
	//比较关系
	if(thisptr->relation != *(inf->recordinf[1]))
	{
	   *ismodfptr = 1;
	   return ;
	}
      //比较固话
	for(count=0;count<inf->ctel;count++)
	{
		pos = 2+count;
		compare = strcmp(inf->recordinf[pos],thisptr->tel[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}

	//比较手机
	for(count=0;count<inf->cmob;count++)
	{
		pos = 2+count+inf->ctel;
		compare = strcmp(inf->recordinf[pos],thisptr->mobile[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较寻呼
	for(count=0;count<inf->cbp;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob;
		compare = strcmp(inf->recordinf[pos],thisptr->bp[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}

	//比较传真
	for(count=0;count<inf->cfax;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp;
		compare = strcmp(inf->recordinf[pos],thisptr->fax[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较单位
	for(count=0;count<inf->cunit;count++)
	{
		pos = 	2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax;
		compare = strcmp(inf->recordinf[pos],thisptr->unit[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较EMAIL
	for(count=0;count<inf->cemail;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit;
		compare = strcmp(inf->recordinf[pos],thisptr->email[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较地址
	for(count=0;count<inf->caddress;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail;
		compare = strcmp(inf->recordinf[pos],thisptr->address[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}

	//比较QQ
	for(count=0;count<inf->cQQ;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail+inf->caddress;
		compare = strcmp(inf->recordinf[pos],thisptr->QQ[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较爱好
	for(count=0;count<inf->chabit;count++)
	{
	   pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail+inf->caddress+inf->cQQ;
		compare = strcmp(inf->recordinf[pos],thisptr->habbit[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}
	//比较邮编
	for(count=0;count<inf->cpostalcode;count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail+inf->caddress+inf->cQQ+inf->chabit;
		compare = strcmp(inf->recordinf[pos],thisptr->postalcode[count]);
		if(compare != 0)	
		{
      		 *ismodfptr = 1;
      		 return ;
		}
	}


	*ismodfptr = 0;
}











//必须确定ctel和cmob和cbp是正确的,因为是有许多地方会修改
STATUS CardSaveModfToSrc(CALLCARD*thisptr,CARDBUFRECORDINF * inf)
{
	U8 count;
	U8 pos;

	//判断指针
	if((inf->recordinf[0])==NULL)
	{
		return ASIX_ERROR;
	}else{
		//thisptr->name = recordinf[0];
		//保存电话	
		strcpy(thisptr->name,inf->recordinf[0]);
	}

	//保存关系
	thisptr->relation = *(inf->recordinf[1]);//因为由于是格式需要,关系也是呈指针的形式


	//错误判断
	if(inf->ctel >MAXTELNUM)      	return ASIX_ERROR;//首先是参数判断
	if(inf->cmob>MAXMOBNUM)    	return ASIX_ERROR;
	if(inf->cbp>MAXBPNUM)         	return ASIX_ERROR;
	if(inf->cfax >MAXFAX)      	   	return ASIX_ERROR;//首先是参数判断
	if(inf->cunit>MAXUNIT)   	   	return ASIX_ERROR;
	if(inf->cemail>MAXEMAIL)          return ASIX_ERROR;
	if(inf->caddress>MAXADDRESS)  return ASIX_ERROR;//首先是参数判断
	if(inf->cQQ>MAXQQ)    		return ASIX_ERROR;
	if(inf->chabit>MAXHABIT)          return ASIX_ERROR;
	if(inf->cpostalcode>MAXPOSTALCODE)         return ASIX_ERROR;

	//保存电话
	for (count =0;count<(inf->ctel);count++)
	{
		pos = 2+count;
		if((*(inf->recordinf[pos])) != 0) 
			 strcpy(thisptr->tel[count],inf->recordinf[pos]);
		  //   thisptr->tel[count] = recordinf[2+count];
	}
	for(count=inf->ctel;count<MAXTELNUM;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->telbuf[count],0x0,MAXTELLEN);	
	}


	//保存手机
	for (count =0;count<(inf->cmob);count++)
	{
	    pos = 2+inf->ctel+count;
	    if(((*inf->recordinf[pos])) != 0)
	    	  strcpy(thisptr->mobile[count],inf->recordinf[pos]);
	}
	for(count=inf->cmob;count<MAXMOBNUM;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->mobbuf[count],0x0,MAXMOBLEN);	
	}

	
	//保存寻呼
	for (count =0;count<(inf->cbp);count++)
	{
		pos = 2+count+inf->ctel+inf->cmob;
		if((*inf->recordinf[pos])!= 0)
			strcpy(thisptr->bp[count],inf->recordinf[pos]);
	}
	for(count=inf->cbp;count<MAXBPNUM;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->bpbuf[count],0x0,MAXBPLEN);	
	}

	//保存传真
	for (count =0;count<(inf->cfax);count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp;
		if((*(inf->recordinf[pos]))!= 0)
			strcpy(thisptr->faxbuf[count],inf->recordinf[pos]);
	}
	 
	for(count=inf->cfax;count<MAXFAX;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->faxbuf[count],0x0,MAXFAXLEN);	
	}

	//保存单位
	for (count =0;count<(inf->cunit);count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax;
		if((*inf->recordinf[pos])!= 0)
			strcpy(thisptr->unit[count],inf->recordinf[pos]);
	}
	for(count=inf->cunit;count<MAXUNIT;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->unitbuf[count],0x0,MAXUNITLEN);	
	}

	//保存EMAIL
	for (count =0;count<(inf->cemail);count++)
	{
		pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit;
		if((*inf->recordinf[pos])!= 0)
			strcpy(thisptr->email[count],inf->recordinf[pos]);
	}
	for(count=inf->cemail;count<MAXEMAIL;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->emailbuf[count],0x0,MAXEMAILLEN);	
	}

	//保存地址
	 for (count =0;count<(inf->caddress);count++)
	{
	   pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail;
	   if((*inf->recordinf[pos])!= 0)
	        strcpy(thisptr->address[count],inf->recordinf[pos]);
	}
	for(count=inf->caddress;count<MAXADDRESS;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->addressbuf[count],0x0,MAXADDRESSLEN);	
	}

	//保存QQ
	 for (count =0;count<(inf->cQQ);count++)
	{
	   pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail+inf->caddress;
	   if((*inf->recordinf[pos])!= 0)
	        strcpy(thisptr->QQ[count],inf->recordinf[pos]);
	}
	for(count=inf->cQQ;count<MAXQQ;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->QQbuf[count],0x0,MAXQQLEN);	
	}

	//保存爱好
	for (count =0;count<(inf->chabit);count++)
	{
	   pos = 2+count+inf->ctel+inf->cmob+inf->cbp+inf->cfax+inf->cunit+inf->cemail+inf->caddress+inf->cQQ;
	   if((*inf->recordinf[pos])!= 0)
	        strcpy(thisptr->habbit[count],inf->recordinf[pos]);
	}
	for(count=inf->chabit;count<MAXHABIT;count++)//对剩下的数据赋零操作
	{
		memset(thisptr->habbitbuf[count],0x0,MAXHABBITLEN);	
	}	

	//保存邮编

⌨️ 快捷键说明

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