soc.2012.statscollector: 3a7e0725: Add detailed operating system info
sanket at soc.pidgin.im
sanket at soc.pidgin.im
Mon May 21 01:56:04 EDT 2012
----------------------------------------------------------------------
Revision: 3a7e0725bd9872a1fb640aec9783bbac597069e5
Parent: 6e5147f00f6d8d71924f5e713981753fab61e1b8
Author: sanket at soc.pidgin.im
Date: 05/18/12 05:24:30
Branch: im.pidgin.soc.2012.statscollector
URL: http://d.pidgin.im/viewmtn/revision/info/3a7e0725bd9872a1fb640aec9783bbac597069e5
Changelog:
Add detailed operating system info
POSIX and Windows expose different interface to analyse operating system
versions. POSIX exposes uname for getting OS information and WINDOWS has
range of functions in GetSystemInfo and GetNativeSystemInfo.
Changes against parent 6e5147f00f6d8d71924f5e713981753fab61e1b8
patched pidgin/plugins/statscollector.c
-------------- next part --------------
============================================================
--- pidgin/plugins/statscollector.c beef962dbc74dae01b6b5467e31152cdcfd7b4a2
+++ pidgin/plugins/statscollector.c 628d5e5ee4db5b0aa9236d2deb89e84699446425
@@ -115,7 +115,7 @@ get_os_32_64(){
BOOL bIsWow64;
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process;
-#elif defined __linux__
+#elif defined __USE_POSIX
struct utsname os_utsname;
char *m_name;
#endif
@@ -141,7 +141,7 @@ get_os_32_64(){
if(bIsWow64) bit_size= 64;
else bit_size = 32;
-#elif defined __linux__
+#elif defined __USE_POSIX
/* Use uname to find kernel architecture and infer bit-size */
uname(&os_utsname);
m_name = os_utsname.machine;
@@ -167,6 +167,9 @@ get_arch(){
struct utsname os_utsname;
#elif defined _WIN32
SYSTEM_INFO sys_info;
+ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
+ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
+ PGNSI pGNSI;
#endif
arch_xml = xmlnode_new("arch");
@@ -176,7 +179,14 @@ get_arch(){
uname(&os_utsname);
arch_str = os_utsname.machine;
#elif defined _WIN32
- GetSystemInfo(&sys_info);
+
+ pGNSI = (PGNSI) GetProcAddress(
+ GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
+
+ if(NULL != pGNSI)
+ pGNSI(&sys_info);
+ else GetSystemInfo(&sys_info);
+
switch(sys_info.wProcessorArchitecture){
case 9:
@@ -208,7 +218,15 @@ get_os_name(){
xmlnode *os_name_xml;
char *name_attrib;
+#ifdef _WIN32
+ xmlnode *major_version, *minor_version;
+ OSVERSIONINFO osvi;
+#elif defined __USE_POSIX
+ xmlnode *os_release, *os_version;
+ struct utsname os_utsname;
+#endif
+
os_name_xml = xmlnode_new("os-info");
#ifdef _WIN32
@@ -221,6 +239,34 @@ get_os_name(){
xmlnode_set_attrib(os_name_xml, "id", name_attrib);
+ /* Get additional information */
+#ifdef _WIN32
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osvi);
+ major_version = xmlnode_new("major-version");
+ minor_version = xmlnode_new("minor-version");
+
+ xmlnode_insert_data(major_version, \
+ g_strdup_printf("%d",osvi.dwMajorVersion),-1);
+ xmlnode_insert_data(minor_version, \
+ g_strdup_printf("%d",osvi.dwMinorVersion),-1);
+
+ xmlnode_insert_child(os_name_xml, major_version);
+ xmlnode_insert_child(os_name_xml, minor_version);
+
+#elif defined __USE_POSIX
+ uname(&os_utsname);
+ os_release = xmlnode_new("release");
+ os_version = xmlnode_new("version");
+ xmlnode_insert_data(os_release, os_utsname.release, -1);
+ xmlnode_insert_data(os_version, os_utsname.version, -1);
+
+ xmlnode_insert_child(os_name_xml, os_release);
+ xmlnode_insert_child(os_name_xml, os_version);
+
+#endif
+
return os_name_xml;
}
More information about the Commits
mailing list