#include#include#include#includetypedefstruct{char hostClass[8];char hostMAC[20];char hostDHCPName[70];char hostDevName[70];char hostIP[20];char hostConnectInterface[8];char hostOnlineTime[64];char hostStotageAccessStatus[8];
}CMCCLanHostInfo;int main(void)
{
FILE*fp =NULL;char line[512] = {0};int i=0;struct tm timeinfo={0};
CMCCLanHostInfo tmp_lhi={0};char if_mac[20]={0};char contype[20]={0};char conssid[20]={0};char ip_addressing[20]={0};char time[128] ="";char *p =NULL;char dest[] = "[]";if ((fp = fopen("pclist_info", "r")) ==NULL) {
printf("%s", "Cannot open pclist_info file!\n");return 0;
}if(fgets(line, sizeof(line)-1 , fp) !=NULL )
{
line[strlen(line)-1] = ‘\0‘;//90:2b:34:67:2b:43 [192.168.10.111] [0] [1] [0 1900/01/00 00:00:00] [Wire] [STATIC] [Online]
sscanf(line, "%[^]%*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]]",
tmp_lhi.hostMAC,
tmp_lhi.hostIP,
tmp_lhi.hostDevName,
tmp_lhi.hostDHCPName,
time,
contype,
ip_addressing,
tmp_lhi.hostClass,
tmp_lhi.hostConnectInterface,
conssid,
tmp_lhi.hostStotageAccessStatus);
printf("hostMAC = %s \n",tmp_lhi.hostMAC);
printf("hostIP = %s \n",tmp_lhi.hostIP);
printf("hostDevName = %s \n",tmp_lhi.hostDevName);
printf("hostDHCPName = %s \n",tmp_lhi.hostDHCPName);
printf("time = %s \n",time);
printf("contype = %s \n",contype);
printf("ip_addressing = %s \n",ip_addressing);
printf("hostClass = %s \n",tmp_lhi.hostClass);
printf("hostConnectInterface = %s \n",tmp_lhi.hostConnectInterface);
printf("conssid = %s \n",conssid);
printf("hostStotageAccessStatus = %s \n",tmp_lhi.hostStotageAccessStatus);
}
fclose(fp);return 0;
}