2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-06 17:45:26 +00:00
Files
bind/lib/isc/win32/win32os.c

101 lines
2.7 KiB
C
Raw Normal View History

2002-08-01 03:40:21 +00:00
/*
2007-06-19 23:47:24 +00:00
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
2004-03-05 05:14:21 +00:00
* Copyright (C) 2002 Internet Software Consortium.
2002-08-01 03:40:21 +00:00
*
2007-06-18 23:47:57 +00:00
* Permission to use, copy, modify, and/or distribute this software for any
2002-08-01 03:40:21 +00:00
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
2004-03-05 05:14:21 +00:00
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
2002-08-01 03:40:21 +00:00
*/
2007-06-19 23:47:24 +00:00
/* $Id: win32os.c,v 1.5 2007/06/19 23:47:19 tbox Exp $ */
2002-08-01 03:40:21 +00:00
#include <windows.h>
#include <isc/win32os.h>
static BOOL bInit = FALSE;
static OSVERSIONINFOEX osVer;
static void
initialize_action(void) {
BOOL bSuccess;
if (bInit)
return;
/*
* NOTE: VC++ 6.0 gets this function declaration wrong
* so we compensate by casting the argument
*/
osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
/*
* Versions of NT before NT4.0 SP6 did not return the
* extra info that the EX structure provides and returns
* a failure so we need to retry with the old structure.
*/
if(!bSuccess) {
osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
}
bInit = TRUE;
}
unsigned int
isc_win32os_majorversion(void) {
initialize_action();
return ((unsigned int)osVer.dwMajorVersion);
}
unsigned int
isc_win32os_minorversion(void) {
initialize_action();
return ((unsigned int)osVer.dwMinorVersion);
}
unsigned int
isc_win32os_servicepackmajor(void) {
initialize_action();
return ((unsigned int)osVer.wServicePackMajor);
}
unsigned int
isc_win32os_servicepackminor(void) {
initialize_action();
return ((unsigned int)osVer.wServicePackMinor);
}
int
isc_win32os_versioncheck(unsigned int major, unsigned int minor,
2002-08-01 03:40:21 +00:00
unsigned int spmajor, unsigned int spminor) {
initialize_action();
if (major < isc_win32os_majorversion())
return (1);
if (major > isc_win32os_majorversion())
2002-08-01 03:40:21 +00:00
return (-1);
if (minor < isc_win32os_minorversion())
2002-08-01 03:40:21 +00:00
return (1);
if (minor > isc_win32os_minorversion())
2002-08-01 03:40:21 +00:00
return (-1);
if (spmajor < isc_win32os_servicepackmajor())
2002-08-01 03:40:21 +00:00
return (1);
if (spmajor > isc_win32os_servicepackmajor())
2002-08-01 03:40:21 +00:00
return (-1);
if (spminor < isc_win32os_servicepackminor())
2002-08-01 03:40:21 +00:00
return (1);
if (spminor > isc_win32os_servicepackminor())
return (-1);
2002-08-01 03:40:21 +00:00
/* Exact */
return (0);
}