if( (ip1Num<=searchIpNum) && (searchIpNum<=ip2Num) )...{
fs.seekg(exeOffset+pos, ios_base::beg);
ip1Num=read4Bit(fs);
#if defined _DEBUG_
cout<<" Last position:"<<endl<<endl;
printIpNum(ip1Num);
cout<<"pos="<<pos<<" ";
#endif
pos=read3Bit(fs);
#if defined _DEBUG_
cout<<"pos="<<pos<<endl;
#endif
fs.seekg(exeOffset+pos, ios_base::beg);
ip2Num=read4Bit(fs);
#if defined _DEBUG_
printIpNum(ip2Num);
#endif
break;
}else if(ip1Num>searchIpNum)...{
endNum = midNum;
}else if(ip2Num<searchIpNum)...{
beginNum = midNum;
}
}
#if defined _DEBUG_
cout<<endl<<"Found position:"<<fs.tellg()<<endl;
#endif
ipAddr=new char[512];
memset(ipAddr, 0, 512);
iRead = readString(fs, exeOffset, ipAddr);
if(iRead>0)...{
cout<<ipAddr<<" ";
}
memset(ipAddr, 0, 512);
iRead = readString(fs, exeOffset, ipAddr);
if(iRead>0)...{
cout<<ipAddr;
}
delete[]ipAddr;
fs.close();
return 0;
}
long read4Bit(ifstream& f)...{
long t; char c[4];
t=0;
f.read((char*)&t, 4);
return t;
}
long read3Bit(ifstream& f)...{
long t;
f.read((char*)&t, 3);
return t;
}
int readString(ifstream& f, long exeOffset, char * str)...{
char ipFlag; long ipSeek, tmpSeek;
int ret;
ipFlag=f.get();
if(ipFlag==0x1) ...{ // 重定向模式1: 城市信息隨國家信息定向
ipSeek=read3Bit(f);
f.seekg(exeOffset+ipSeek, ios_base::beg);