Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
4.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (c) Microsoft Corporation. All rights reserved.
  5. //
  6. // File: guiddef.h
  7. //
  8. // Contents: GUID definition
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef GUID_DEFINED
  12. #define GUID_DEFINED
  13. #if defined(__midl)
  14. typedef struct {
  15. unsigned long Data1;
  16. unsigned short Data2;
  17. unsigned short Data3;
  18. byte Data4[ 8 ];
  19. } GUID;
  20. #else
  21. typedef struct _GUID {
  22. unsigned long Data1;
  23. unsigned short Data2;
  24. unsigned short Data3;
  25. unsigned char Data4[ 8 ];
  26. } GUID;
  27. #endif
  28. #endif
  29. #ifndef FAR
  30. #ifdef _WIN32
  31. #define FAR
  32. #else
  33. #define FAR _far
  34. #endif
  35. #endif
  36. #ifndef DECLSPEC_SELECTANY
  37. #if (_MSC_VER >= 1100)
  38. #define DECLSPEC_SELECTANY __declspec(selectany)
  39. #else
  40. #define DECLSPEC_SELECTANY
  41. #endif
  42. #endif
  43. #ifndef EXTERN_C
  44. #ifdef __cplusplus
  45. #define EXTERN_C extern "C"
  46. #else
  47. #define EXTERN_C extern
  48. #endif
  49. #endif
  50. #ifdef DEFINE_GUID
  51. #undef DEFINE_GUID
  52. #endif
  53. #ifdef INITGUID
  54. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  55. EXTERN_C const GUID DECLSPEC_SELECTANY name \
  56. = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  57. #else
  58. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  59. EXTERN_C const GUID FAR name
  60. #endif // INITGUID
  61. #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  62. #ifndef _GUIDDEF_H_
  63. #define _GUIDDEF_H_
  64. #ifndef __LPGUID_DEFINED__
  65. #define __LPGUID_DEFINED__
  66. typedef GUID *LPGUID;
  67. #endif
  68. #ifndef __LPCGUID_DEFINED__
  69. #define __LPCGUID_DEFINED__
  70. typedef const GUID *LPCGUID;
  71. #endif
  72. #ifndef __IID_DEFINED__
  73. #define __IID_DEFINED__
  74. typedef GUID IID;
  75. typedef IID *LPIID;
  76. #define IID_NULL GUID_NULL
  77. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  78. typedef GUID CLSID;
  79. typedef CLSID *LPCLSID;
  80. #define CLSID_NULL GUID_NULL
  81. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  82. typedef GUID FMTID;
  83. typedef FMTID *LPFMTID;
  84. #define FMTID_NULL GUID_NULL
  85. #define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
  86. #ifdef __midl_proxy
  87. #define __MIDL_CONST
  88. #else
  89. #define __MIDL_CONST const
  90. #endif
  91. #ifndef _REFGUID_DEFINED
  92. #define _REFGUID_DEFINED
  93. #ifdef __cplusplus
  94. #define REFGUID const GUID &
  95. #else
  96. #define REFGUID const GUID * __MIDL_CONST
  97. #endif
  98. #endif
  99. #ifndef _REFIID_DEFINED
  100. #define _REFIID_DEFINED
  101. #ifdef __cplusplus
  102. #define REFIID const IID &
  103. #else
  104. #define REFIID const IID * __MIDL_CONST
  105. #endif
  106. #endif
  107. #ifndef _REFCLSID_DEFINED
  108. #define _REFCLSID_DEFINED
  109. #ifdef __cplusplus
  110. #define REFCLSID const IID &
  111. #else
  112. #define REFCLSID const IID * __MIDL_CONST
  113. #endif
  114. #endif
  115. #ifndef _REFFMTID_DEFINED
  116. #define _REFFMTID_DEFINED
  117. #ifdef __cplusplus
  118. #define REFFMTID const IID &
  119. #else
  120. #define REFFMTID const IID * __MIDL_CONST
  121. #endif
  122. #endif
  123. #endif // !__IID_DEFINED__
  124. #if !defined (__midl)
  125. #if !defined (_SYS_GUID_OPERATORS_)
  126. #define _SYS_GUID_OPERATORS_
  127. #include <string.h>
  128. // Faster (but makes code fatter) inline version...use sparingly
  129. #ifdef __cplusplus
  130. __inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  131. {
  132. return (
  133. ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
  134. ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
  135. ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
  136. ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
  137. }
  138. __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  139. {
  140. return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  141. }
  142. #else // ! __cplusplus
  143. #define InlineIsEqualGUID(rguid1, rguid2) \
  144. (((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] && \
  145. ((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] && \
  146. ((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] && \
  147. ((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
  148. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  149. #endif // __cplusplus
  150. #ifdef __INLINE_ISEQUAL_GUID
  151. #undef IsEqualGUID
  152. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
  153. #endif
  154. // Same type, different name
  155. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  156. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  157. #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
  158. #define _SYS_GUID_OPERATOR_EQ_
  159. // A couple of C++ helpers
  160. #ifdef __cplusplus
  161. __inline int operator==(REFGUID guidOne, REFGUID guidOther)
  162. {
  163. return IsEqualGUID(guidOne,guidOther);
  164. }
  165. __inline int operator!=(REFGUID guidOne, REFGUID guidOther)
  166. {
  167. return !(guidOne == guidOther);
  168. }
  169. #endif
  170. #endif // _SYS_GUID_OPERATOR_EQ_
  171. #endif // _SYS_GUID_OPERATORS_
  172. #endif // __midl
  173. #endif // _GUIDDEF_H_