3 * $Id: win32.cc,v 1.3 2001/10/19 22:34:49 hno 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
== 1)) {
53 WIN32_OS_string
= xstrdup("Windows XP");
56 WIN32_OS_string
= xstrdup("Windows 2000");
59 case VER_PLATFORM_WIN32_WINDOWS
:
60 if ((osvi
.dwMajorVersion
> 4) ||
61 ((osvi
.dwMajorVersion
== 4) && (osvi
.dwMinorVersion
> 0))) {
62 WIN32_OS_string
= xstrdup("Windows 98");
65 WIN32_OS_string
= xstrdup("Windows 95");
68 case VER_PLATFORM_WIN32s
:
69 WIN32_OS_string
= xstrdup("Windows 3.1 with WIN32S");
70 return _WIN_OS_WIN32S
;
73 return _WIN_OS_UNKNOWN
;
75 WIN32_OS_string
= xstrdup("Unknown");
76 return _WIN_OS_UNKNOWN
;
79 /* ====================================================================== */
80 /* PUBLIC FUNCTIONS */
81 /* ====================================================================== */
90 WIN32_Subsystem_Init()
92 WIN32_OS_version
= GetOSVersion();
93 if ((WIN32_OS_version
== _WIN_OS_UNKNOWN
) || (WIN32_OS_version
== _WIN_OS_WIN32S
))
95 if (atexit(WIN32_Exit
) != 0)