首页 > 新闻系统 > 编程天地 > 文章正文

C++查詢wry.dat中的IP地址信息代码

2008-03-24 15:56:54 来源:中国自学编程网 作者:佚名 点击:
直接上代碼(哪一位有不明白的地方,請留言):

       ret=readString(f, exeOffset, str);
    }else if(ipFlag == 0x2) ...{ // 重定向模式2: 城市信息沒有隨國家信息定向
        ipSeek=read3Bit(f);
        tmpSeek=f.tellg();
        f.seekg(exeOffset+ipSeek, ios_base::beg);
        ret=readString(f, exeOffset, str);
        f.seekg(exeOffset+tmpSeek, ios_base::beg);
    } else ...{
        f.seekg(-1, ios_base::cur);
        ret=read2Zero(f, str);
    }
    return ret;
}

int read2Zero(ifstream& f, char*buf)...{
    f.get(buf, 128, 0);
    return strlen(buf);
}


void printHelp(char* exePath)...{
    char *fileName;
    fileName=strrchr(exePath,’\’);
    if(fileName==NULL)...{
        strcpy(fileName, exePath);
    }else...{
        fileName++;
    }
    cout<<endl
        <<"Wry IP Search Beta by cangwu.lee@gmail.com "
        <<"Usage:"
        <<" "<<fileName<<"<ip address> <Path to wry.dat> "
        <<endl;
    free(fileName);
}


DWORD convertIP(char*sip)...{

    char *c1, *c2, *c3, *c4;
    DWORD i1, i2, i3, i4, dd;

#if defined _DEBUG_
    cout<<" ip="<<sip<<endl;
#endif

    c1 = strtok(sip, " ,.-");
    if(c1==NULL)...{
        cout<<"IP address incorrect."<<endl;
        return 0;
     }
    c2 = strtok(NULL," ,.-");if(c2==NULL)c2="0";
    c3 = strtok(NULL," ,.-");if(c3==NULL)c3="0";
    c4 = strtok(NULL," ,.-");if(c4==NULL)c4="0";
    i1=atol(c1); i2=atol(c2); i3=atol(c3); i4=atol(c4);
    if(i1<0 || i2<0 || i3<0 || i4<0
        || i1>254 || i2>255 || i3>255 || i4>255)...{
        cout<<"IP address incorrect."<<endl;
        delete[]c1;      delete[]c2;     delete[]c3;     delete[]c4;
        return 0;
    }
9 7 3 1 2 3 4 5 4 8 :

精彩推荐
焦点大图推荐
本类热门文章

论坛美图

广告联系 | 版权说明 | 意见建议 | 加入收藏 | 军网站群 [ 军软件园 - 军软件商城 - 军软件园论坛 ]

电信与信息服务业务经营许可证:京ICP证050203