📄 carddb.c
字号:
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((P_S8)(*(recordinf->tel[count]))!= NULL)
{
countctel++;
}
}
sourceinf->ctel = countctel;
for (count =0;count<(MAXMOBNUM);count++)
{
if((P_S8)(*(recordinf->mobile[count]))!= NULL)//modified on 0920 因为是指向内存区域,但是不为空
{
countcmob++;
}
}
sourceinf->cmob = countcmob;
for (count =0;count<(MAXBPNUM);count++)
{
if((P_S8)(*(recordinf->bp[count]))!= NULL)
{
countcbp++;
}
}
sourceinf->cbp = countcbp;
for (count =0;count<(MAXFAX);count++)
{
if((P_S8)(*(recordinf->fax[count]))!= NULL)
{
countcfax++;
}
}
sourceinf->cfax = countcfax;
for (count =0;count<(MAXUNIT);count++)
{
if((P_S8)(*(recordinf->unit[count]))!= NULL)
{
countcunit++;
}
}
sourceinf->cunit = countcunit;
for (count =0;count<(MAXEMAIL);count++)
{
if((P_S8)(*(recordinf->email[count]))!= NULL)
{
countcemail++;
}
}
sourceinf->cemail = countcemail;
for (count =0;count<(MAXADDRESS);count++)
{
if((P_S8)(*(recordinf->address[count]))!= NULL)
{
countcaddress++;
}
}
sourceinf->caddress= countcaddress;
for (count =0;count<(MAXQQ);count++)
{
if((P_S8)(*(recordinf->QQ[count]))!= NULL)
{
countcQQ++;
}
}
sourceinf->cQQ= countcQQ;
for (count =0;count<(MAXHABIT);count++)
{
if((P_S8)(*(recordinf->habbit[count]))!= NULL)
{
countchabit++;
}
}
sourceinf->chabit= countchabit;
for (count =0;count<(MAXPOSTALCODE);count++)
{
if((P_S8)(*(recordinf->postalcode[count]))!= NULL)
{
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((P_S8)(*(inf->recordinf[pos])) != NULL)
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(((P_S8)(*inf->recordinf[pos])) != NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
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((P_S8)(*(inf->recordinf[pos]))!= NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
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((P_S8)(*inf->recordinf[pos])!= NULL)
strcpy(thisptr->habbit[count],inf->recordinf[pos]);
}
for(count=inf->chabit;count<MAXHABIT;count++)//对剩下的数据赋零操作
{
memset(thisptr->habbitbuf[count],0x0,MAXHABBITLEN);
}
//保存邮编
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;
if((P_S8)(*inf->recordinf[pos])!= NULL)
strcpy(thisptr->postalcode[count],inf->recordinf[pos]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -