]> git.ipfire.org Git - thirdparty/squid.git/blob - src/win32.cc
SSL update from the "ssl" branch at SourceForge
[thirdparty/squid.git] / src / win32.cc
1
2 /*
3 * $Id: win32.cc,v 1.3 2001/10/19 22:34:49 hno 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 == 1)) {
53 WIN32_OS_string = xstrdup("Windows XP");
54 return _WIN_OS_WINXP;
55 }
56 WIN32_OS_string = xstrdup("Windows 2000");
57 return _WIN_OS_WIN2K;
58 break;
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");
63 return _WIN_OS_WIN98;
64 }
65 WIN32_OS_string = xstrdup("Windows 95");
66 return _WIN_OS_WIN95;
67 break;
68 case VER_PLATFORM_WIN32s:
69 WIN32_OS_string = xstrdup("Windows 3.1 with WIN32S");
70 return _WIN_OS_WIN32S;
71 break;
72 default:
73 return _WIN_OS_UNKNOWN;
74 }
75 WIN32_OS_string = xstrdup("Unknown");
76 return _WIN_OS_UNKNOWN;
77 }
78
79 /* ====================================================================== */
80 /* PUBLIC FUNCTIONS */
81 /* ====================================================================== */
82
83 void
84 WIN32_Exit()
85 {
86 _exit(0);
87 }
88
89 int
90 WIN32_Subsystem_Init()
91 {
92 WIN32_OS_version = GetOSVersion();
93 if ((WIN32_OS_version == _WIN_OS_UNKNOWN) || (WIN32_OS_version == _WIN_OS_WIN32S))
94 return 1;
95 if (atexit(WIN32_Exit) != 0)
96 return 1;
97 return 0;
98 }
99 #endif