Ticket #277: 277.2.diff

File 277.2.diff, 4.3 KB (added by Silvan Scherrer, 11 years ago)

2nd try

  • src/corelib/global/qglobal.cpp

     
    12711271    \value OV_ECS_1_1           eComStation 1.1
    12721272    \value OV_ECS_1_2           eComStation 1.2
    12731273    \value OV_ECS_2_0           eComStation 2.0 (either any of RCs or GA)
     1274    \value OV_ECS_2_1           eComStation 2.1 (either any of RCs or GA)
     1275    \value OV_ECS_2_2           eComStation 2.2 (either any of RCs or GA)
    12741276
    12751277    The following masks can be used for detecting properties common to a group
    12761278    of versions:
     
    19711973// Returns a version number of the component taken directly from its SYSLEVEL
    19721974// file (see http://www.edm2.com/index.php/Using_SYSLEVEL_Files_in_Your_Applications
    19731975// for more information about SYSLEVEL file internals)
    1974 static bool getSyslevelVersion(const QByteArray &fileName, char (*version)[2])
     1976// beginning from ecs 2.1 they changed the detection scheme once more
     1977// the information is now in the ecs_inst.flg file as plain text
     1978// the below function deals with both
     1979 enum fileType {
     1980    SysLevel,
     1981    eCSFlg };
     1982
     1983static bool getSyslevelVersion(const QByteArray &fileName, char *version, fileType ft)
    19751984{
    19761985    bool success = false;
     1986    int offSet;
     1987    size_t bytesToR;
     1988
     1989    if (ft == SysLevel)
     1990    {
     1991        offSet = 0x28;
     1992        bytesToR = 2;
     1993    } else {
     1994        offSet = 0x0C;
     1995        bytesToR = 3;
     1996    }
     1997
    19771998    FILE *f = fopen(fileName, "rb");
    19781999    if (!f)
    19792000        return success;
    1980     // go to the char d_version[2] field of the SYSLEVEL data structure
    1981     if ((success = fseek(f, 0x28, SEEK_SET) == 0)) {
     2001    // go to the offset of the data structure
     2002    if ((success = fseek(f, offSet, SEEK_SET) == 0)) {
    19822003        // read in two bytes
    1983         success = fread(*version, 1, 2, f) == 2;
     2004        success = fread(version, 1, bytesToR, f) == bytesToR;
    19842005    }
    19852006    fclose(f);
    19862007    return success;
     
    20252046    QByteArray fn = QByteArray("A:\\OS2\\INSTALL\\SYSLEVEL.OS2");
    20262047    fn.data()[0] += buf[0] - 1;
    20272048    char sys_os2_ver[2];
    2028     if (!getSyslevelVersion(fn, &sys_os2_ver))
     2049    if (!getSyslevelVersion(fn, sys_os2_ver, SysLevel))
    20292050        return os2ver;
    20302051
    20312052    // read SYSLEVEL.ECS
    20322053    fn = QByteArray("A:\\OS2\\INSTALL\\SYSLEVEL.ECS");
    20332054    fn.data()[0] += buf[0] - 1;
    20342055    char sys_ecs_ver[2];
    2035     if (!getSyslevelVersion(fn, &sys_ecs_ver)) {
     2056    if (!getSyslevelVersion(fn, sys_ecs_ver, SysLevel)) {
    20362057        // no or broken SYSLEVEL.ECS, it's either eCS 1.1 or below or non-eCS
    20372058        bool have_ecsreg = false;
    20382059        bool have_ecsreg11 = false;
     
    20492070        if (have_ecsreg)
    20502071            return os2ver = OV_ECS_1_0;
    20512072        // detect WSeB (4.52)
    2052         if (sys_os2_ver[0] == 0x45 &&sys_os2_ver[1] == 0x02)
     2073        if (sys_os2_ver[0] == 0x45 && sys_os2_ver[1] == 0x02)
    20532074            return os2ver = OV_4_52;
    20542075        // fallback to Aurora (QSV_VERSION_MINOR is 45 here)
    20552076        return os2ver = OV_4_5;
     
    20582079    // detect eCS >= 1.2
    20592080    if (sys_ecs_ver[0] == 0x12 && sys_ecs_ver[1] == 0x00)
    20602081        return os2ver = OV_ECS_1_2;
    2061     if (sys_ecs_ver[0] == 0x20 && sys_ecs_ver[1] == 0x00)
    2062         return os2ver = OV_ECS_2_0;
     2082    if (sys_ecs_ver[0] >= 0x20 && sys_ecs_ver[1] == 0x00)
     2083    {
     2084        os2ver = OV_ECS_2_0;
     2085        // read ecs_inst.flg
     2086        char flg_ecs_ver[3];
     2087        fn = QByteArray("A:\\ECS\\ECS_INST.FLG");
     2088        fn.data()[0] += buf[0] - 1;
     2089        if (getSyslevelVersion(fn, flg_ecs_ver, eCSFlg)) {
     2090           if (flg_ecs_ver[0] == '2' && flg_ecs_ver[2] == '1')
     2091               os2ver = OV_ECS_2_1;
     2092           if (flg_ecs_ver[0] == '2' && flg_ecs_ver[2] == '2')
     2093               os2ver = OV_ECS_2_2;
     2094        }
     2095        return os2ver;
     2096    }
    20632097
    20642098    return os2ver = OV_ECS_Unknown;
    20652099}
  • src/corelib/global/qglobal.h

     
    15661566        OV_ECS_1_1      = 0x06010100,
    15671567        OV_ECS_1_2      = 0x06010200,
    15681568        OV_ECS_2_0      = 0x06020000,
     1569        OV_ECS_2_1      = 0x06020100,
     1570        OV_ECS_2_2      = 0x06020200,
    15691571
    15701572        /* version masks */
    15711573        OV_WARP3        = 0x01000000,