1 /*
2 
3 Copyright 1996, 1998  The Open Group
4 
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10 
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
17 SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-
18 ITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 IN THE SOFTWARE.
21 
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization from
25 The Open Group.
26 
27 */
28 
29 /*
30  * This header file has the sole purpose of allowing the inclusion of
31  * windows.h without getting any name conflicts with X headers code, by
32  * renaming or disabling the conflicting definitions from windows.h
33  */
34 
35 /*
36  * Mingw.org versions of the Windows API headers actually avoid
37  * making the conflicting definitions if XFree86Server is defined, so we
38  * need to remember if that was defined and undefine it during including
39  * windows.h (so the conflicting definitions get wrapped correctly), and
40  * then redefine it afterwards. (This was never the correct thing to
41  * do as it's no help at all to X11 clients which also need to use the
42  * Win32 API)
43  */
44 #undef _XFree86Server
45 #ifdef XFree86Server
46 # define _XFree86Server
47 # undef XFree86Server
48 #endif
49 
50 /*
51  * There doesn't seem to be a good way to wrap the min/max macros from
52  * windows.h, so we simply avoid defining them completely, allowing any
53  * pre-existing definition to stand.
54  *
55  */
56 #define NOMINMAX
57 
58 /*
59  * mingw-w64 headers define BOOL as a typedef, protecting against macros
60  * mingw.org headers define BOOL in terms of WINBOOL
61  * ... so try to come up with something which works with both :-)
62  */
63 #define _NO_BOOL_TYPEDEF
64 #define BOOL WINBOOL
65 #define INT32 wINT32
66 #ifdef __x86_64__
67 #define INT64 wINT64
68 #define LONG64 wLONG64
69 #endif
70 #undef Status
71 #define Status wStatus
72 #define ATOM wATOM
73 #define BYTE wBYTE
74 #define FreeResource wFreeResource
75 #include <windows.h>
76 #undef NOMINMAX
77 #undef Status
78 #define Status int
79 #undef BYTE
80 #undef BOOL
81 #undef INT32
82 #undef INT64
83 #undef LONG64
84 #undef ATOM
85 #undef FreeResource
86 #undef CreateWindowA
87 
88 /*
89  * Older version of this header used to name the windows API bool type wBOOL,
90  * rather than more standard name WINBOOL
91  */
92 #define wBOOL WINBOOL
93 
94 #ifdef RESOURCE_H
95 # undef RT_FONT
96 # undef RT_CURSOR
97 # define RT_FONT         ((RESTYPE)4)
98 # define RT_CURSOR       ((RESTYPE)5)
99 #endif
100 
101 #ifndef __CYGWIN__
102 #define sleep(x) Sleep((x) * 1000)
103 #endif
104 
105 #if defined(WIN32) && (!defined(PATH_MAX) || PATH_MAX < 1024)
106 # undef PATH_MAX
107 # define PATH_MAX 1024
108 #endif
109 
110 #ifdef _XFree86Server
111 # define XFree86Server
112 # undef _XFree86Server
113 #endif
114 
115