]> git.ipfire.org Git - thirdparty/squid.git/blob - src/win32.cc
Import of fix-ranges branch
[thirdparty/squid.git] / src / win32.cc
1
2 /*
3 * $Id: win32.cc,v 1.6 2003/01/23 00:37:29 robertc Exp $
4 *
5 * * * * * * * * Legal stuff * * * * * * *
6 *
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.
13 *
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.
18 *
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.
22 *
23 */
24
25 #include "squid.h"
26
27 /* This code compiles only CygWin & Windows NT Port */
28 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
29 #include <windows.h>
30
31 static unsigned int GetOSVersion();
32
33 /* ====================================================================== */
34 /* LOCAL FUNCTIONS */
35 /* ====================================================================== */
36
37 static unsigned int
38 GetOSVersion()
39 {
40 OSVERSIONINFO osvi;
41
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");
50 return _WIN_OS_WINNT;
51 }
52 if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 0)) {
53 WIN32_OS_string = xstrdup("Windows 2000");
54 return _WIN_OS_WIN2K;
55 }
56 if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 1)) {
57 WIN32_OS_string = xstrdup("Windows XP");
58 return _WIN_OS_WINXP;
59 }
60 if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 2)) {
61 WIN32_OS_string = xstrdup("Windows .NET");
62 return _WIN_OS_WINNET;
63 }
64 break;
65 case VER_PLATFORM_WIN32_WINDOWS:
66 if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 0)) {
67 WIN32_OS_string = xstrdup("Windows 95");
68 return _WIN_OS_WIN95;
69 }
70 if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 10)) {
71 WIN32_OS_string = xstrdup("Windows 98");
72 return _WIN_OS_WIN98;
73 }
74 if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 90)) {
75 WIN32_OS_string = xstrdup("Windows Me");
76 return _WIN_OS_WINME;
77 }
78 break;
79 case VER_PLATFORM_WIN32s:
80 WIN32_OS_string = xstrdup("Windows 3.1 with WIN32S");
81 return _WIN_OS_WIN32S;
82 break;
83 default:
84 break;
85 }
86 WIN32_OS_string = xstrdup("Unknown Windows system");
87 return _WIN_OS_UNKNOWN;
88 }
89
90 /* ====================================================================== */
91 /* PUBLIC FUNCTIONS */
92 /* ====================================================================== */
93
94 void
95 WIN32_Exit()
96 {
97 _exit(0);
98 }
99
100 int
101 WIN32_Subsystem_Init()
102 {
103 WIN32_OS_version = GetOSVersion();
104 if ((WIN32_OS_version == _WIN_OS_UNKNOWN) || (WIN32_OS_version == _WIN_OS_WIN32S))
105 return 1;
106 if (atexit(WIN32_Exit) != 0)
107 return 1;
108 return 0;
109 }
110 #endif