~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to ports/winnt/libisc/win32os.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2002 Internet Software Consortium.
 
3
 *
 
4
 * Permission to use, copy, modify, and distribute this software for any
 
5
 * purpose with or without fee is hereby granted, provided that the above
 
6
 * copyright notice and this permission notice appear in all copies.
 
7
 *
 
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 
9
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 
10
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 
11
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 
12
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 
13
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
14
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
15
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
16
 */
 
17
 
 
18
/* $Id: win32os.c,v 1.2 2002/08/03 01:36:24 mayer Exp $ */
 
19
 
 
20
#include <windows.h>
 
21
 
 
22
#include <isc/win32os.h>
 
23
 
 
24
static BOOL bInit = FALSE;
 
25
static OSVERSIONINFOEX osVer;
 
26
 
 
27
static void
 
28
initialize_action(void) {
 
29
        BOOL bSuccess;
 
30
 
 
31
        if (bInit)
 
32
                return; 
 
33
        /*
 
34
         * NOTE: VC++ 6.0 gets this function declaration wrong
 
35
         * so we compensate by casting the argument
 
36
         */
 
37
        osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
 
38
        bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
 
39
 
 
40
        /*
 
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.
 
44
         */
 
45
        if(!bSuccess) {
 
46
                osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 
47
                bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
 
48
        }
 
49
        bInit = TRUE;
 
50
}
 
51
 
 
52
unsigned int
 
53
isc_win32os_majorversion(void) {
 
54
        initialize_action();
 
55
        return ((unsigned int)osVer.dwMajorVersion);
 
56
}
 
57
 
 
58
unsigned int
 
59
isc_win32os_minorversion(void) {
 
60
        initialize_action();
 
61
        return ((unsigned int)osVer.dwMinorVersion);
 
62
}
 
63
 
 
64
unsigned int
 
65
isc_win32os_servicepackmajor(void) {
 
66
        initialize_action();
 
67
        return ((unsigned int)osVer.wServicePackMajor);
 
68
}
 
69
 
 
70
unsigned int
 
71
isc_win32os_servicepackminor(void) {
 
72
        initialize_action();
 
73
        return ((unsigned int)osVer.wServicePackMinor);
 
74
}
 
75
 
 
76
int
 
77
isc_win32os_versioncheck(unsigned int major, unsigned int minor,
 
78
                     unsigned int spmajor, unsigned int spminor) {
 
79
 
 
80
        initialize_action();
 
81
 
 
82
        if (major < isc_win32os_majorversion())
 
83
                return (1);
 
84
        if (major > isc_win32os_majorversion())
 
85
                return (-1);
 
86
        if (minor < isc_win32os_minorversion())
 
87
                return (1);
 
88
        if (minor > isc_win32os_minorversion())
 
89
                return (-1);
 
90
        if (spmajor < isc_win32os_servicepackmajor())
 
91
                return (1);
 
92
        if (spmajor > isc_win32os_servicepackmajor())
 
93
                return (-1);
 
94
        if (spminor < isc_win32os_servicepackminor())
 
95
                return (1);
 
96
        if (spminor > isc_win32os_servicepackminor())
 
97
                return (-1);
 
98
 
 
99
        /* Exact */
 
100
        return (0);
 
101
}
 
 
b'\\ No newline at end of file'