github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/jxr/jxrlib/common/include/guiddef.h (about)

     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  // Faster (but makes code fatter) inline version...use sparingly
   174  #ifdef __cplusplus
   175  __inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
   176  {
   177     return (
   178        ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
   179        ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
   180        ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
   181        ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
   182  }
   183  
   184  __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
   185  {
   186      return !memcmp(&rguid1, &rguid2, sizeof(GUID));
   187  }
   188  
   189  #else   // ! __cplusplus
   190  
   191  #define InlineIsEqualGUID(rguid1, rguid2)  \
   192          (((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] &&   \
   193          ((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] &&    \
   194          ((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] &&    \
   195          ((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
   196  
   197  #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
   198  
   199  #endif  // __cplusplus
   200  
   201  #ifdef __INLINE_ISEQUAL_GUID
   202  #undef IsEqualGUID
   203  #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
   204  #endif
   205  
   206  // Same type, different name
   207  
   208  #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
   209  #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
   210  
   211  
   212  #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
   213  #define _SYS_GUID_OPERATOR_EQ_
   214  // A couple of C++ helpers
   215  
   216  #ifdef __cplusplus
   217  __inline int operator==(REFGUID guidOne, REFGUID guidOther)
   218  {
   219      return IsEqualGUID(guidOne,guidOther);
   220  }
   221  
   222  __inline int operator!=(REFGUID guidOne, REFGUID guidOther)
   223  {
   224      return !(guidOne == guidOther);
   225  }
   226  #endif
   227  #endif  // _SYS_GUID_OPERATOR_EQ_
   228  #endif  // _SYS_GUID_OPERATORS_
   229  #endif  // __midl
   230  #endif  // _GUIDDEF_H_