2 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: win32os.c,v 1.5 2007/06/19 23:47:19 tbox Exp $ */
22 #include <isc/win32os.h>
24 static BOOL bInit = FALSE;
25 static OSVERSIONINFOEX osVer;
28 initialize_action(void) {
34 * NOTE: VC++ 6.0 gets this function declaration wrong
35 * so we compensate by casting the argument
37 osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
38 bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
41 * Versions of NT before NT4.0 SP6 did not return the
42 * extra info that the EX structure provides and returns
43 * a failure so we need to retry with the old structure.
46 osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
47 bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
53 isc_win32os_majorversion(void) {
55 return ((unsigned int)osVer.dwMajorVersion);
59 isc_win32os_minorversion(void) {
61 return ((unsigned int)osVer.dwMinorVersion);
65 isc_win32os_servicepackmajor(void) {
67 return ((unsigned int)osVer.wServicePackMajor);
71 isc_win32os_servicepackminor(void) {
73 return ((unsigned int)osVer.wServicePackMinor);
77 isc_win32os_versioncheck(unsigned int major, unsigned int minor,
78 unsigned int spmajor, unsigned int spminor) {
82 if (major < isc_win32os_majorversion())
84 if (major > isc_win32os_majorversion())
86 if (minor < isc_win32os_minorversion())
88 if (minor > isc_win32os_minorversion())
90 if (spmajor < isc_win32os_servicepackmajor())
92 if (spmajor > isc_win32os_servicepackmajor())
94 if (spminor < isc_win32os_servicepackminor())
96 if (spminor > isc_win32os_servicepackminor())