Coverage Report

Created: 2025-06-22 08:04

/src/jxrlib/common/include/guiddef.h
Line
Count
Source (jump to first uncovered line)
1
//+---------------------------------------------------------------------------
2
//
3
// Copyright © Microsoft Corp.
4
// All rights reserved.
5
// 
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
// 
9
// • Redistributions of source code must retain the above copyright notice,
10
//   this list of conditions and the following disclaimer.
11
// • Redistributions in binary form must reproduce the above copyright notice,
12
//   this list of conditions and the following disclaimer in the documentation
13
//   and/or other materials provided with the distribution.
14
// 
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
26
//
27
//  File:       guiddef.h
28
//
29
//  Contents:   GUID definition
30
//
31
//----------------------------------------------------------------------------
32
33
#ifndef GUID_DEFINED
34
#define GUID_DEFINED
35
#if defined(__midl)
36
typedef struct {
37
    unsigned long  Data1;
38
    unsigned short Data2;
39
    unsigned short Data3;
40
    byte           Data4[ 8 ];
41
} GUID;
42
#else
43
typedef struct _GUID {
44
#if defined(_WINDOWS_) || !__LP64__
45
    unsigned long  Data1;
46
#else
47
    unsigned int   Data1;
48
#endif
49
    unsigned short Data2;
50
    unsigned short Data3;
51
    unsigned char  Data4[ 8 ];
52
} GUID;
53
#endif
54
#endif
55
56
#ifndef FAR
57
#if defined(_WIN32) || defined(__ANSI__)
58
#define FAR
59
#else
60
#define FAR _far
61
#endif
62
#endif
63
64
#ifndef DECLSPEC_SELECTANY
65
#if (_MSC_VER >= 1100)
66
#define DECLSPEC_SELECTANY  __declspec(selectany)
67
#else
68
#define DECLSPEC_SELECTANY
69
#endif
70
#endif
71
72
#ifndef EXTERN_C
73
#ifdef __cplusplus
74
#define EXTERN_C    extern "C"
75
#else
76
#define EXTERN_C    extern
77
#endif
78
#endif
79
80
#ifdef DEFINE_GUID
81
#undef DEFINE_GUID
82
#endif
83
84
#ifdef INITGUID
85
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
86
        const GUID DECLSPEC_SELECTANY name \
87
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
88
#else
89
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
90
    EXTERN_C const GUID FAR name
91
#endif // INITGUID
92
93
#define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
94
95
#ifndef _GUIDDEF_H_
96
#define _GUIDDEF_H_
97
98
#ifndef __LPGUID_DEFINED__
99
#define __LPGUID_DEFINED__
100
typedef GUID *LPGUID;
101
#endif
102
103
#ifndef __LPCGUID_DEFINED__
104
#define __LPCGUID_DEFINED__
105
typedef const GUID *LPCGUID;
106
#endif
107
108
#ifndef __IID_DEFINED__
109
#define __IID_DEFINED__
110
111
typedef GUID IID;
112
typedef IID *LPIID;
113
#define IID_NULL            GUID_NULL
114
#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
115
typedef GUID CLSID;
116
typedef CLSID *LPCLSID;
117
#define CLSID_NULL          GUID_NULL
118
#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
119
typedef GUID FMTID;
120
typedef FMTID *LPFMTID;
121
#define FMTID_NULL          GUID_NULL
122
#define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
123
124
#ifdef __midl_proxy
125
#define __MIDL_CONST
126
#else
127
#define __MIDL_CONST const
128
#endif
129
130
#ifndef _REFGUID_DEFINED
131
#define _REFGUID_DEFINED
132
#ifdef __cplusplus
133
#define REFGUID const GUID &
134
#else
135
#define REFGUID const GUID * __MIDL_CONST
136
#endif
137
#endif
138
139
#ifndef _REFIID_DEFINED
140
#define _REFIID_DEFINED
141
#ifdef __cplusplus
142
#define REFIID const IID &
143
#else
144
#define REFIID const IID * __MIDL_CONST
145
#endif
146
#endif
147
148
#ifndef _REFCLSID_DEFINED
149
#define _REFCLSID_DEFINED
150
#ifdef __cplusplus
151
#define REFCLSID const IID &
152
#else
153
#define REFCLSID const IID * __MIDL_CONST
154
#endif
155
#endif
156
157
#ifndef _REFFMTID_DEFINED
158
#define _REFFMTID_DEFINED
159
#ifdef __cplusplus
160
#define REFFMTID const IID &
161
#else
162
#define REFFMTID const IID * __MIDL_CONST
163
#endif
164
#endif
165
166
#endif // !__IID_DEFINED__
167
168
#if !defined (__midl)
169
#if !defined (_SYS_GUID_OPERATORS_)
170
#define _SYS_GUID_OPERATORS_
171
#include <string.h>
172
173
#if defined(__unix__) || defined(__APPLE__) // fix compilation error under macOS and Linux
174
#include <wchar.h>
175
#endif
176
177
// Faster (but makes code fatter) inline version...use sparingly
178
#ifdef __cplusplus
179
__inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
180
0
{
181
0
   return (
182
0
      ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
183
0
      ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
184
0
      ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
185
0
      ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
186
0
}
187
188
__inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
189
8.06k
{
190
8.06k
    return !memcmp(&rguid1, &rguid2, sizeof(GUID));
191
8.06k
}
192
193
#else   // ! __cplusplus
194
195
#define InlineIsEqualGUID(rguid1, rguid2)  \
196
        (((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] &&   \
197
        ((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] &&    \
198
        ((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] &&    \
199
        ((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
200
201
#define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
202
203
#endif  // __cplusplus
204
205
#ifdef __INLINE_ISEQUAL_GUID
206
#undef IsEqualGUID
207
#define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
208
#endif
209
210
// Same type, different name
211
212
#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
213
#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
214
215
216
#if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
217
#define _SYS_GUID_OPERATOR_EQ_
218
// A couple of C++ helpers
219
220
#ifdef __cplusplus
221
__inline int operator==(REFGUID guidOne, REFGUID guidOther)
222
0
{
223
0
    return IsEqualGUID(guidOne,guidOther);
224
0
}
225
226
__inline int operator!=(REFGUID guidOne, REFGUID guidOther)
227
0
{
228
0
    return !(guidOne == guidOther);
229
0
}
230
#endif
231
#endif  // _SYS_GUID_OPERATOR_EQ_
232
#endif  // _SYS_GUID_OPERATORS_
233
#endif  // __midl
234
#endif  // _GUIDDEF_H_