1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #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);
- }
|