diff -urN xchat-2.4.5/src/common/util.c xc/src/common/util.c --- xchat-2.4.5/src/common/util.c 2005-07-13 02:44:32.000000000 -0400 +++ xc/src/common/util.c 2005-09-22 19:50:32.000000000 -0400 @@ -483,7 +483,162 @@ new_str[i] = 0; return new_str; -} +} + +#define X86_VENDOR_INTEL 0 +#define X86_VENDOR_CYRIX 1 +#define X86_VENDOR_AMD 2 +#define X86_VENDOR_UMC 3 +#define X86_VENDOR_NEXGEN 4 +#define X86_VENDOR_CENTAUR 5 +#define X86_VENDOR_RISE 6 +#define X86_VENDOR_TRANSMETA 7 +#define X86_VENDOR_NSC 8 +#define MAX_INFO_LENGTH 30 + +static struct CpuInfo +{ + int nVendor; + int nFamily; + char *pszModelNames[16]; +} CpuModels[] = { + { X86_VENDOR_INTEL, 4, + { "486 DX-25/33", "486 DX-50", "486 SX", "486 DX/2", "486 SL", + "486 SX/2", NULL, "486 DX/2-WB", "486 DX/4", "486 DX/4-WB", NULL, + NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_INTEL, 5, + { "Pentium 60/66 A-step", "Pentium 60/66", "Pentium 75-200", + "OverDrive PODP5V83", "Pentium MMX", NULL, NULL, + "Mobile Pentium 75-200", "Mobile Pentium MMX", NULL, NULL, NULL, + NULL, NULL, NULL, NULL } }, + { X86_VENDOR_INTEL, 6, + { "Pentium Pro A-step", "Pentium Pro", NULL, "Pentium 2", NULL, + "Pentium 2", "Mobile Pentium 2", "Pentium 3", "Pentium 3", NULL, + "Pentium 3", NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_INTEL, 15, + { "Pentium 4", "Pentium 4", "Pentium 4", "Pentium 4", "Pentium 4", + "Pentium 4", "Pentium 4", "Pentium 4", "Pentium 4", "Pentium 4", + NULL, NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_AMD, 4, + { NULL, NULL, NULL, "486 DX/2", NULL, NULL, NULL, "486 DX/2-WB", + "486 DX/4", "486 DX/4-WB", NULL, NULL, NULL, NULL, "Am5x86-WT", + "Am5x86-WB" } }, + { X86_VENDOR_AMD, 5, + { "K5/SSA5", "K5", "K5", "K5", NULL, NULL, "K6", "K6", "K6-2", "K6-3", + NULL, NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_AMD, 6, + { "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", + "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon", "Athlon" } }, + { X86_VENDOR_AMD, 7, + { "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", + "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64" } }, + { X86_VENDOR_AMD, 15, + { "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", + "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64", "Athlon 64" } }, + { X86_VENDOR_UMC, 4, + { NULL, "U5D", "U5S", NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_NEXGEN, 5, + { "Nx586", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL } }, + { X86_VENDOR_RISE, 5, + { "iDragon", NULL, "iDragon", NULL, NULL, NULL, NULL, + NULL, "iDragon II", "iDragon II", NULL, NULL, NULL, NULL, NULL, NULL } + } +}; + +char *GetCpuType (char *szCpuType) +{ + char szVendor[MAX_INFO_LENGTH + 1] = ""; + int nVendor, nFamily, nModel; + + HKEY hKey; + SYSTEM_INFO sys; + GetSystemInfo(&sys); + nFamily = sys.wProcessorLevel; + nModel = sys.wProcessorRevision >> 8; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "Hardware\\Description\\System\\CentralProcessor\\0", + 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + unsigned long nSize = sizeof(szVendor); + RegQueryValueEx(hKey, "VendorIdentifier", NULL, NULL, + (LPBYTE) szVendor, &nSize); + RegCloseKey(hKey); + } + + if (!strcmp(szVendor, "GenuineIntel")) + { + if (nFamily == 3) + { + return strcpy(szCpuType, "Intel 386"); + } + strcpy(szCpuType, "Intel"); + nVendor = X86_VENDOR_INTEL; + } + else if (!strcmp(szVendor, "AuthenticAMD")) + { + strcpy(szCpuType, "AMD"); + nVendor = X86_VENDOR_AMD; + } + else if (!strcmp(szVendor, "CyrixInstead")) + { + strcpy(szCpuType, "Cyrix"); + nVendor = X86_VENDOR_CYRIX; + } + else if (!strcmp(szVendor, "Geode by NSC")) + { + strcpy(szCpuType, "Geode"); + nVendor = X86_VENDOR_NSC; + } + else if (!strcmp(szVendor, "UMC UMC UMC ")) + { + strcpy(szVendor, "UMC"); + nVendor = X86_VENDOR_UMC; + } + else if (!strcmp(szVendor, "CentaurHauls")) + { + strcpy(szCpuType, "Centaur"); + nVendor = X86_VENDOR_CENTAUR; + } + else if (!strcmp(szVendor, "NexGenDriven")) + { + strcpy(szCpuType, "NexGen"); + nVendor = X86_VENDOR_NEXGEN; + } + else if (!strcmp(szVendor, "RiseRiseRise")) + { + strcpy(szCpuType, "Rise"); + nVendor = X86_VENDOR_RISE; + } + else if (!strcmp(szVendor, "GenuineTMx86") || + !strcmp(szVendor, "TransmetaCPU")) + { + strcpy(szCpuType, szVendor); + nVendor = X86_VENDOR_TRANSMETA; + } + else + { + return strcpy(szCpuType, "(unknown)"); + } + + if (nModel < 16) + { + unsigned int i; + struct CpuInfo *pInfo = CpuModels; + for (i = 0; i < sizeof(CpuModels)/sizeof(struct CpuInfo); i++, pInfo++) + { + if (pInfo->nVendor == nVendor && pInfo->nFamily == nFamily) + { + wsprintf(szCpuType, "%s %s", szCpuType, pInfo->pszModelNames[nModel]); + break; + } + } + } + + return(szCpuType); +} #if defined (USING_LINUX) || defined (USING_FREEBSD) || defined (__APPLE__) @@ -606,22 +761,49 @@ OSVERSIONINFO osvi; SYSTEM_INFO si; double mhz; - + + char szCpuType[30]; + char winver[30]; + GetCpuType(szCpuType); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); GetVersionEx (&osvi); - GetSystemInfo (&si); - + GetSystemInfo (&si); +if (VER_PLATFORM_WIN32_NT) { + switch (osvi.dwMajorVersion) { + case 5: + if (osvi.dwMinorVersion == 0) strcpy(winver,"2000"); + if (osvi.dwMinorVersion == 1) strcpy(winver,"XP"); + if (osvi.dwMinorVersion == 2) strcpy(winver,"2003"); + break; + case 6: + strcpy(winver,"Vista"); + break; + default: + sprintf(winver,"NT %d",osvi.dwMajorVersion); + } +} +else { + switch (osvi.dwMajorVersion) { + case 4: + if (osvi.dwMinorVersion==0) strcpy(winver,"95"); + if (osvi.dwMinorVersion==10) strcpy(winver,"98"); + if (osvi.dwMinorVersion==90) strcpy(winver,"ME"); + break; + default: + sprintf(winver,"%d",osvi.dwMajorVersion); + } +} mhz = get_mhz (); if (mhz) { double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz; const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz"; - sprintf (verbuf, "Windows %ld.%ld [i%d86/%.2f%s]", - osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel, + sprintf (verbuf, "Windows %s [%s/%.2f%s]", + winver, szCpuType, cpuspeed, cpuspeedstr); } else - sprintf (verbuf, "Windows %ld.%ld [i%d86]", - osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel); + sprintf (verbuf, "Windows %s [%s]", + winver, szCpuType); return verbuf; }