倒数据入数据结构
strchr()sscanf()atoi()
1.SwShortMsgHandle("MASTER:58.246.176.194;2032;1;CMNET;NICK;PASSWORD");
2.void SwShortMsgHandle(char* content){
。。。。
else if(CheckPrefix(content,"MASTER"))
{
TRACE(LOG,"enter ABC\n");
ParseGprsLnkParam(strchr(content,':')+1,&sw_gprs_link_cfg.master);
}
}
3.void ParseGprsLnkParam(char *src,sw_gprs_lnk_info_T *param)
{
char buf[60]={0};
int i=0;
int ii=1;
int n=0;
sscanf(src,"%[^;]",buf);
TRACE(LOG,"xing1\n");
sw_gprs_link_cfg.master.ipaddr[0]=(byte)atoi(&buf[0]);
TRACE(LOG,"sw_gprs_link_cfg.master.ipaddr[0] IS %d\n",sw_gprs_link_cfg.master.ipaddr[0]);
while(buf[i]!='\0')
{
while(buf[i]=='.')
{
i++;
sw_gprs_link_cfg.master.ipaddr[ii]=(byte)atoi(&buf[i]);
TRACE(LOG,"sw_gprs_link_cfg.master.ipaddr[%d] IS %d\n",ii,sw_gprs_link_cfg.master.ipaddr[ii]);
ii++;
}
i++;
}
i=0;
ii=0;
sscanf(src,"%s",buf);
TRACE(LOG,"BUF IS %s\n",buf);
while(buf[i]!='\0')
{
while((buf[i]==';')&&(ii==0))
{
i++;
sw_gprs_link_cfg.master.port=atoi(&buf[i]);
TRACE(LOG,"sw_gprs_link_cfg.master.port IS %d\n",sw_gprs_link_cfg.master.port);
ii++;
}
while((buf[i]==';')&&(ii==1))
{
i++;
sw_gprs_link_cfg.master.type=atoi(&buf[i]);
TRACE(LOG,"sw_gprs_link_cfg.master.type IS %d\n",sw_gprs_link_cfg.master.type);
ii++;
}
while((buf[i]==';')&&(ii==2))
{
i++;
while(buf[i]!=';')
{
sw_gprs_link_cfg.master.apn[n]=buf[i];
i++;
n++;
}
TRACE(LOG,"sw_gprs_link_cfg.master.apn IS %s\n",sw_gprs_link_cfg.master.apn);
ii++;
}
while((buf[i]==';')&&(ii==3))
{
i++;
n=0;
while(buf[i]!=';')
{
sw_gprs_link_cfg.master.name[n]=buf[i];
i++;
n++;
}
TRACE(LOG,"sw_gprs_link_cfg.master.nickname IS %s\n",sw_gprs_link_cfg.master.name);
ii++;
}
while((buf[i]==';')&&(ii==4))
{
i++;
n=0;
while(buf[i]!=';')
{
sw_gprs_link_cfg.master.password[n]=buf[i];
i++;
n++;
}
TRACE(LOG,"sw_gprs_link_cfg.master.password IS %s\n",sw_gprs_link_cfg.master.password);
ii++;
}
i++;
}
阅读(1833) | 评论(0) | 转发(0) |