Changed GUID_DEFINED to _GUID_DEFINED for compatibility (prevent conflict) with mingw...
[reactos.git] / reactos / include / ole32 / guiddef.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: include\ole32\guiddef.h
5 * PURPOSE: Guid definition macros
6 * PROGRAMMER: jurgen van gael [jurgen.vangael@student.kuleuven.ac.be]
7 * UPDATE HISTORY:
8 * Created 05/01/2001
9 */
10 /********************************************************************
11
12
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Library General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Library General Public License for more details.
22
23 You should have received a copy of the GNU Library General Public
24 License along with this library; see the file COPYING.LIB. If
25 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
26 Cambridge, MA 02139, USA.
27
28
29 ********************************************************************/
30 #ifndef _GUIDDEF_H
31 #define _GUIDDEF_H
32
33 #include <string.h>
34
35
36 #ifndef EXTERN_C
37 #ifdef __cplusplus
38 #define EXTERN_C extern "C"
39 #else
40 #define EXTERN_C extern
41 #endif
42 #endif
43
44
45 // guid definition
46 #ifndef _GUID_DEFINED
47 #define _GUID_DEFINED
48 typedef struct _GUID {
49 unsigned long Data1;
50 unsigned short Data2;
51 unsigned short Data3;
52 unsigned char Data4[ 8 ];
53 } GUID;
54 typedef GUID* LPGUID;
55 typedef const GUID* LPCGUID;
56 #endif
57
58
59 // guid definition macro
60 #ifdef DEFINE_GUID
61 #undef DEFINE_GUID
62 #endif
63
64 #ifdef INITGUID
65 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
66 const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
67 #else
68 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
69 const GUID name
70 #endif
71 #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
72
73
74 // IID section
75 typedef GUID IID;
76 typedef IID* LPIID;
77 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
78
79
80 // CLSID section
81 typedef GUID CLSID;
82 typedef CLSID* LPCLSID;
83 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
84
85 // FMTID
86 typedef GUID FMTID;
87 typedef FMTID* LPFMTID;
88 #define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
89
90
91 // REFGUID section
92 #ifndef _REFGUID_DEFINED
93 #define _REFGUID_DEFINED
94 #ifdef __cplusplus
95 #define REFGUID const GUID &
96 #else
97 #define REFGUID const GUID *
98 #endif
99 #endif
100
101 // REFIID section
102 #ifndef _REFIID_DEFINED
103 #define _REFIID_DEFINED
104 #ifdef __cplusplus
105 #define REFIID const IID &
106 #else
107 #define REFIID const IID *
108 #endif
109 #endif
110
111 // REFCLSID section
112 #ifndef _REFCLSID_DEFINED
113 #define _REFCLSID_DEFINED
114 #ifdef __cplusplus
115 #define REFCLSID const IID &
116 #else
117 #define REFCLSID const IID *
118 #endif
119 #endif
120
121 // REFFMTID section
122 #ifndef _REFFMTID_DEFINED
123 #define _REFFMTID_DEFINED
124 #ifdef __cplusplus
125 #define REFFMTID const IID &
126 #else
127 #define REFFMTID const IID *
128 #endif
129 #endif
130
131
132 // compare functions for GUID
133 #ifdef __cplusplus
134 // cpp versions
135 __inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
136 {
137 return(((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
138 ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
139 ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
140 ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
141 }
142 __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
143 {
144 return !memcmp(&rguid1, &rguid2, sizeof(GUID));
145 }
146 #else
147 // c versions
148 #define InlineIsEqualGUID(rguid1, rguid2) \
149 (((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] && \
150 ((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] && \
151 ((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] && \
152 ((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
153
154 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
155 #endif
156
157 // use the inline version???
158 #ifdef __INLINE_ISEQUAL_GUID
159 #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
160 #endif
161
162
163 // compare functions for IID CLSID
164 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
165 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
166
167 // c++ helper functions
168 #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
169 #define _SYS_GUID_OPERATOR_EQ_
170 #ifdef __cplusplus
171 __inline int operator==(REFGUID guidOne, REFGUID guidTwo)
172 {
173 return IsEqualGUID(guidOne ,guidTwo);
174 }
175
176 __inline int operator!=(REFGUID guidOne, REFGUID guidTwo)
177 {
178 return !(guidOne == guidTwo);
179 }
180 #endif
181 #endif
182
183 #endif