svnno****@sourc*****
svnno****@sourc*****
Thu Apr 5 13:57:35 JST 2007
Revision: 3150 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3150 Author: kous Date: 2007-04-05 13:57:35 +0900 (Thu, 05 Apr 2007) Log Message: ----------- * configure.ac: check whether sys/utsname.h is available or not. * src/utils/utils.c (kz_win32_get_system_name): added fallback function. * module/embed/ie/kz-ie.cpp: removed needless include. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/configure.ac kazehakase/trunk/module/embed/ie/kz-ie.cpp kazehakase/trunk/src/utils/utils.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-05 03:50:09 UTC (rev 3149) +++ kazehakase/trunk/ChangeLog 2007-04-05 04:57:35 UTC (rev 3150) @@ -1,5 +1,12 @@ 2007-04-05 Kouhei Sutou <kou****@cozmi*****> + * configure.ac: check whether sys/utsname.h is available or not. + + * src/utils/utils.c (kz_win32_get_system_name): added fallback + function. + + * module/embed/ie/kz-ie.cpp: removed needless include. + * src/kz-app.[ch], src/kazehakase.h, src/Makefile.am, configure.ac, src/kz-embed.c, src/kz-ext.c, src/kz-search.c, ext/ruby/kz-rb-ext.c: used KZ_GET_* macros for getting directory name. Modified: kazehakase/trunk/configure.ac =================================================================== --- kazehakase/trunk/configure.ac 2007-04-05 03:50:09 UTC (rev 3149) +++ kazehakase/trunk/configure.ac 2007-04-05 04:57:35 UTC (rev 3150) @@ -261,6 +261,7 @@ dnl ************************************************************** AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h libintl.h stdlib.h string.h unistd.h]) +AC_CHECK_HEADERS([sys/utsname.h]) dnl ************************************************************** Modified: kazehakase/trunk/module/embed/ie/kz-ie.cpp =================================================================== --- kazehakase/trunk/module/embed/ie/kz-ie.cpp 2007-04-05 03:50:09 UTC (rev 3149) +++ kazehakase/trunk/module/embed/ie/kz-ie.cpp 2007-04-05 04:57:35 UTC (rev 3150) @@ -22,7 +22,6 @@ #include <glib/gi18n.h> #include <math.h> -#include <sys/utsname.h> #include "kazehakase.h" #include "kz-ie.h" Modified: kazehakase/trunk/src/utils/utils.c =================================================================== --- kazehakase/trunk/src/utils/utils.c 2007-04-05 03:50:09 UTC (rev 3149) +++ kazehakase/trunk/src/utils/utils.c 2007-04-05 04:57:35 UTC (rev 3150) @@ -31,7 +31,9 @@ #ifdef HAVE_UNISTD_H # include <unistd.h> #endif -#include <sys/utsname.h> +#ifdef HAVE_SYS_UTSNAME_H +# include <sys/utsname.h> +#endif #include "utils.h" #include "glib-utils.h" @@ -40,6 +42,10 @@ #include "kazehakase.h" #include "kz-search.h" +#ifdef G_OS_WIN32 +# include <windows.h> +#endif + #define BUFFER_SIZE 1024 #define TIME_STAMP_FORMAT "%ld,%s\n" @@ -1062,23 +1068,103 @@ return last_component_encoded_uri; } +#ifdef G_OS_WIN32 +static gchar * +kz_win32_get_system_name (void) +{ + gchar *system = NULL; + OSVERSIONINFO version; + + version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&version); + + switch (version.dwPlatformId) + { + case VER_PLATFORM_WIN32s: + break; + case VER_PLATFORM_WIN32_WINDOWS: + if (version.dwMinorVersion == 0) + { + system = g_strdup("Windows 95"); + break; + } + + if (version.dwMinorVersion == 10) + { + system = g_strdup("Windows 98"); + break; + } + + if (version.dwMinorVersion == 90) + { + system = g_strdup("Windows Me"); + break; + } + + break; + case VER_PLATFORM_WIN32_NT: + if (version.dwMajorVersion == 5 && + version.dwMinorVersion == 0) + { + system = g_strdup_printf("Windows 2000 with %s", + version.szCSDVersion); + break; + } + + if (version.dwMajorVersion == 5 && + version.dwMinorVersion == 1) + { + system = g_strdup_printf("Windows XP %s", + version.szCSDVersion); + break; + } + + if (version.dwMajorVersion <= 4) + { + system = g_strdup_printf("Windows NT %ld.%ld with %s", + version.dwMajorVersion, + version.dwMinorVersion, + version.szCSDVersion); + break; + } + + break; + } + + if (!system) + system = g_strdup_printf("Windows %ld.%ld", + version.dwMajorVersion, + version.dwMinorVersion); + + return system; +} +#endif + gchar * kz_utils_get_system_name (void) { - struct utsname name; - gchar *system; + gchar *system = NULL; - if (uname (&name) >= 0) +#ifdef HAVE_SYS_UTSNAME_H { - system = g_strdup_printf ("%s %s", - name.sysname, - name.machine); + struct utsname name; + if (uname(&name) >= 0) + { + system = g_strdup_printf("%s %s", + name.sysname, + name.machine); + } } - else - { - system = g_strdup ("Unknown"); - } - +#endif + +#ifdef G_OS_WIN32 + if (!system) + system = kz_win32_get_system_name(); +#endif + + if (!system) + system = g_strdup("Unknown"); + return system; }