SyncML在藍牙車載信息娛樂設(shè)備上的設(shè)計與實現(xiàn)
unsigned int vcard_parse(void)
{
unsigned int cnt,end,i,phone_index;
char* p;
end=vcard_length;
value_initia();
/*begin to parse vcard*/
for (cnt=13; cnt after"BEGIN:VCARD"*/
{
if((0xd==an_complete_vcard[cnt])&&(0xa==an_
complete_vcard[cnt+1]))
{
/*extract a property,another property parameter or vcard end*/
cnt=cnt+2;/*skip rn*/
/*if vcard end*/
p=&an_complete_vcard[cnt];
if(0==uCompareASCIIName(p,"END:VCARD",9))
{
if(vcard_cmd==ADD)
{
phonebook_insert();
}//the vcard cmd ADD
else if(vcard_cmd==REPLACE)
{
}// the vcard cmd REPLACE
return 0;
}else if(0==uCompareASCIIName(p,"TEL;",4))
{
cnt=cnt+4;/* TEL property ,first skip "TEL;"*/ …
p=&an_complete_vcard[cnt];
if(0==uCompareASCIIName(p,"PREF",4))/*mobile
phonenumber*/
{
cnt=cnt+4;/*skip the "PREF"*/
...
cnt=cnt-2;/*check next rn,in the "for",cnt++,so -2,not -1*/
}else if(0==uCompareASCIIName(p,"VOICE",5))
{
}else if(0==uCompareASCIIName(p,"CELL",4))
{
}else if(0==uCompareASCIIName(p,"HOME",4))
{
}else if(0==uCompareASCIIName(p,"WORK",4))
{
} else if(0==uCompareASCIIName(p,"CAR",3))
{
}
} else if(0==uCompareASCIIName(p,"TEL:",4))
{ //some phone’s telephone have no parameter,
for example TEL:10086
}else if(0==uCompareASCIIName(p,"N",1))
{ //name property
}
}
}
return 0;
}
其中,uCompareASCIIName是比較字符串函數(shù),對輸入的兩個字符串不分大小寫按字節(jié)進行比較,具體代碼略。
評論