3 * $Id: win32.cc,v 1.6 2003/01/23 00:37:29 robertc Exp $
5 * * * * * * * * Legal stuff * * * * * * *
7 * (C) 2001 Guido Serassio <serassio@libero.it>,
8 * inspired by previous work by Romeo Anghelache & Eric Stern.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 /* This code compiles only CygWin & Windows NT Port */
28 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
31 static unsigned int GetOSVersion();
33 /* ====================================================================== */
35 /* ====================================================================== */
42 safe_free(WIN32_OS_string
);
43 memset(&osvi
, '\0', sizeof(OSVERSIONINFO
));
44 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
45 GetVersionEx((OSVERSIONINFO
*) & osvi
);
46 switch (osvi
.dwPlatformId
) {
47 case VER_PLATFORM_WIN32_NT
:
48 if (osvi
.dwMajorVersion
<= 4) {
49 WIN32_OS_string
= xstrdup("Windows NT");
52 if ((osvi
.dwMajorVersion
== 5) && (osvi
.dwMinorVersion
== 0)) {
53 WIN32_OS_string
= xstrdup("Windows 2000");
56 if ((osvi
.dwMajorVersion
== 5) && (osvi
.dwMinorVersion
== 1)) {
57 WIN32_OS_string
= xstrdup("Windows XP");
60 if ((osvi
.dwMajorVersion
== 5) && (osvi
.dwMinorVersion
== 2)) {
61 WIN32_OS_string
= xstrdup("Windows .NET");
62 return _WIN_OS_WINNET
;
65 case VER_PLATFORM_WIN32_WINDOWS
:
66 if ((osvi
.dwMajorVersion
== 4) && (osvi
.dwMinorVersion
== 0)) {
67 WIN32_OS_string
= xstrdup("Windows 95");
70 if ((osvi
.dwMajorVersion
== 4) && (osvi
.dwMinorVersion
== 10)) {
71 WIN32_OS_string
= xstrdup("Windows 98");
74 if ((osvi
.dwMajorVersion
== 4) && (osvi
.dwMinorVersion
== 90)) {
75 WIN32_OS_string
= xstrdup("Windows Me");
79 case VER_PLATFORM_WIN32s
:
80 WIN32_OS_string
= xstrdup("Windows 3.1 with WIN32S");
81 return _WIN_OS_WIN32S
;
86 WIN32_OS_string
= xstrdup("Unknown Windows system");
87 return _WIN_OS_UNKNOWN
;
90 /* ====================================================================== */
91 /* PUBLIC FUNCTIONS */
92 /* ====================================================================== */
101 WIN32_Subsystem_Init()
103 WIN32_OS_version
= GetOSVersion();
104 if ((WIN32_OS_version
== _WIN_OS_UNKNOWN
) || (WIN32_OS_version
== _WIN_OS_WIN32S
))
106 if (atexit(WIN32_Exit
) != 0)