From d03d6e606b40157d910ddf99ab018156abeb8ef0 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Mon, 28 Feb 2011 18:59:32 +0100 Subject: add wdk changes to named branch --- src/common/util.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 16 deletions(-) (limited to 'src/common/util.c') diff --git a/src/common/util.c b/src/common/util.c index 49517ec4..67168a5f 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -16,11 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#define WANTSOCKET +#include "inet.h" /* make it first to avoid macro redefinitions */ + #define __APPLE_API_STRICT_CONFORMANCE #define _FILE_OFFSET_BITS 64 #include -#include #include #include #include @@ -35,7 +37,7 @@ #include #endif #include -#include +#include "dirent.h" #include #include "xchat.h" #include "xchatc.h" @@ -44,9 +46,6 @@ #include "util.h" #include "../../config.h" -#define WANTSOCKET -#include "inet.h" - #if defined (USING_FREEBSD) || defined (__APPLE__) #include #endif @@ -54,9 +53,11 @@ #include #endif +#ifndef ENABLE_NLS #ifndef HAVE_SNPRINTF #define snprintf g_snprintf #endif +#endif #ifdef USE_DEBUG @@ -383,6 +384,28 @@ waitline (int sok, char *buf, int bufsize, int use_recv) } } +#ifdef WIN32 +/* waitline2 using win32 file descriptor and glib instead of _read. win32 can't _read() sok! */ +int +waitline2 (GIOChannel *source, char *buf, int bufsize) +{ + int i = 0; + int len; + + while (1) + { + if (g_io_channel_read (source, &buf[i], 1, &len) != G_IO_ERROR_NONE) + return -1; + if (buf[i] == '\n' || bufsize == i + 1) + { + buf[i] = 0; + return i; + } + i++; + } +} +#endif + /* checks for "~" in a file and expands */ char * @@ -628,26 +651,79 @@ char * get_cpu_str (void) { static char verbuf[64]; - OSVERSIONINFO osvi; - SYSTEM_INFO si; + static char winver[20]; + OSVERSIONINFOEX osvi; double mhz; - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); GetVersionEx (&osvi); - GetSystemInfo (&si); + + switch (osvi.dwMajorVersion) + { + case 5: + switch (osvi.dwMinorVersion) + { + case 1: + strcpy (winver, "XP"); + break; + case 2: + if (osvi.wProductType == VER_NT_WORKSTATION) + { + strcpy (winver, "XP x64 Edition"); + } + else + { + if (GetSystemMetrics(SM_SERVERR2) == 0) + { + strcpy (winver, "Server 2003"); + } + else + { + strcpy (winver, "Server 2003 R2"); + } + } + break; + } + break; + case 6: + switch (osvi.dwMinorVersion) + { + case 0: + if (osvi.wProductType == VER_NT_WORKSTATION) + { + strcpy (winver, "Vista"); + } + else + { + strcpy (winver, "Server 2008"); + } + break; + case 1: + if (osvi.wProductType == VER_NT_WORKSTATION) + { + strcpy (winver, "7"); + } + else + { + strcpy (winver, "Server 2008 R2"); + } + break; + } + break; + } 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, - cpuspeed, cpuspeedstr); - } else - sprintf (verbuf, "Windows %ld.%ld [i%d86]", - osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel); - + sprintf (verbuf, "Windows %s [%.2f%s]", winver, cpuspeed, cpuspeedstr); + } + else + { + sprintf (verbuf, "Windows %s", winver); + } + return verbuf; } -- cgit 1.4.1 From b85f311ddd7a1275e49289ba935617a163062790 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Mon, 30 May 2011 21:15:39 +0200 Subject: move cpu arch stuff to separate function --- src/common/util.c | 18 ++++++++++++++++++ src/common/util.h | 1 + src/fe-gtk/about.c | 15 +-------------- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src/common/util.c') diff --git a/src/common/util.c b/src/common/util.c index 67168a5f..5677e82a 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -647,6 +647,24 @@ get_mhz (void) return 0; /* fails on Win9x */ } +int +get_cpu_arch (void) +{ + SYSTEM_INFO si; + unsigned short int cpu_arch; + + GetSystemInfo (&si); + + if (si.wProcessorArchitecture == 9) + { + return 64; + } + else + { + return 86; + } +} + char * get_cpu_str (void) { diff --git a/src/common/util.h b/src/common/util.h index cd9e1fff..92d2a843 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -45,6 +45,7 @@ char *errorstring (int err); int waitline (int sok, char *buf, int bufsize, int); #ifdef WIN32 int waitline2 (GIOChannel *source, char *buf, int bufsize); +int get_cpu_arch (void); #else #define waitline2(source,buf,size) waitline(serv->childread,buf,size,0) #endif diff --git a/src/fe-gtk/about.c b/src/fe-gtk/about.c index 453d405c..6e69b646 100644 --- a/src/fe-gtk/about.c +++ b/src/fe-gtk/about.c @@ -88,19 +88,6 @@ menu_about (GtkWidget * wid, gpointer sess) char buf[512]; const char *locale = NULL; extern GtkWindow *parent_window; /* maingui.c */ - SYSTEM_INFO si; - unsigned short int cpu_arch; - - GetSystemInfo (&si); - - if (si.wProcessorArchitecture == 9) - { - cpu_arch = 64; - } - else - { - cpu_arch = 86; - } if (about) { @@ -146,7 +133,7 @@ menu_about (GtkWidget * wid, gpointer sess) gtk_minor_version, gtk_micro_version, (portable_mode () ? "Yes" : "No"), - cpu_arch + get_cpu_arch () #else "%s\n\n" "%s\n" -- cgit 1.4.1