#include "common.h" int GetParaFromStr(char *Str,char *Para,char *Value){ int ValueLen=0,ParaLen=0; char ParaTemp[22]; char *p; char d; int i=0; if(0==*Str || 0==*Para)return 0; while(0!=(d=*Para) && ParaLen<20){ ParaTemp[i++]=d; if(d=='=' || d==';')return 0; Para++; ParaLen++; } ParaTemp[ParaLen++]='='; ParaTemp[ParaLen]=0; p=strstr(Str,ParaTemp); p+=ParaLen; //-- while(*p>0x20 && ';'!=*p && ValueLen<=80){ *Value=*p; p++; Value++; ValueLen++; } *Value=0; return ValueLen; } char msgCmp(char *msg, char *target){ char *p1=target, *p2=msg; while(*p1 != 0){ if(*p1 != *p2) return 0; p1++;p2++; } return 1; } // '56'->0X56 unsigned char charStrToHex(char d1, char d2){ unsigned char p1=d1; unsigned char p2=d2; if(p1>='0' && p1 <='9') p1 -= 0x30; else if(p1>='a' && p1 <='f') p1 -= 0x57; else if(p1>='A' && p1 <='F') p1 -= 0x37; else return 0; p1<<=4;p1&=0xF0; if(p2>='0' && p2 <='9') p2 -= 0x30; else if(p2>='a' && p2 <='f') p2 -= 0x57; else if(p2>='A' && p2 <='F') p2 -= 0x37; else return 0; return (p1|p2); } /* restoreDataFormatByHex "313233"=>{0x31,0x32,0x33} */ T_INT8 restoreDataFormatByHex(T_UINT8 *src, T_UINT16 len) { T_UINT16 i,j,k; T_UINT8 temp[2]; if(NULL==src) return 1; j=0; for(i=0;i='0' && temp[k]<='9') temp[k] -= 0x30; else if(temp[k]>='a' && temp[k]<='f') temp[k] -= 0x57; else if(temp[k]>='A' && temp[k]<='F') temp[k] -= 0x37; else return 2; } temp[0] <<= 4; temp[0] &= 0xF0; src[j++] = temp[0] | temp[1]; } return 0; } /* fillByHexFormat {0x31,0x32,0x33}=>"313233"=>src */ void fillByHexFormat(T_INT8 *src, T_INT8 *data, T_INT32 len){ T_INT32 i; T_INT8 buf[10]; for(i=0;i= 'a' && data[i] <= 'z') data[i] -= 0x20; } } /******************************************************************* fitStrForIndex 从Str中查找Para串 return:-1 未找到目标串 return:>=0 找到目标串返回目标在源串的索引值 ********************************************************************/ T_INT16 fitStrForIndex(T_INT8 *Str,T_INT8 *Para){ T_INT8 *targetP; targetP=strstr(Str, Para); if(targetP==0) return -1; else{ return (targetP-Str); } } unsigned char AscToHex(unsigned char aHex) { if((aHex>=0)&&(aHex<=9)) aHex += 0x30; else if((aHex>=10)&&(aHex<=15))//A-F //aHex += 0x37; aHex += 0x57; else aHex = 0xff; return aHex; } void AscStrTurnHexStr(char *AscStr, char *HexStr) { char *pAscStr=AscStr; unsigned char d,h,l; while(0!=(d=(unsigned char)*pAscStr++)){ l=d&0x0f; h=d>>4; *HexStr++=AscToHex(h); *HexStr++=AscToHex(l); } *HexStr=0; } /*0x12-->12*/ unsigned char bcdToDec(unsigned char value){ unsigned char h,l; h=(value>>4)&0x0f; l=value&0x0f; return (h*10+l); } void LwEndingToBiEndingStr(char *data, int len){ char tt[2]; int i; for(i=0;iyear=poc_clock.year; myclock->month=poc_clock.month; myclock->day=poc_clock.day; myclock->hour=poc_clock.hour; myclock->min=poc_clock.min; myclock->sec=poc_clock.sec; } void ohpocGetClock(MY_CLOCK *myclock){ getMyClock(myclock); }