/soc/2012/sanket/statscollector-2.x.y: a32567664e00: Add detaile...

Sanket Agarwal sanket at soc.pidgin.im
Tue Jul 10 00:36:23 EDT 2012


Changeset: a32567664e00ba549905df3b72c3dcafa3d6d8bf
Author:	 Sanket Agarwal <sanket at soc.pidgin.im>
Date:	 2012-05-18 09:24 +0000
Branch:	 soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/a32567664e00

Description:

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.

diffstat:

 pidgin/plugins/statscollector.c |  52 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 3 deletions(-)

diffs (97 lines):

diff --git a/pidgin/plugins/statscollector.c b/pidgin/plugins/statscollector.c
--- a/pidgin/plugins/statscollector.c
+++ b/pidgin/plugins/statscollector.c
@@ -115,7 +115,7 @@
   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 @@
   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 @@
   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 @@
   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,6 +218,14 @@
 
   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");
 
@@ -221,6 +239,34 @@
 
   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