Leaked source code of windows server 2003
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.

250 lines
5.4 KiB

  1. /*
  2. * U N K O B J . H
  3. *
  4. * This is a generic definition of the IUnknown (plus GetLastError) part
  5. * of objects that are derived from IUnknown with GetLastError.
  6. *
  7. * Used in:
  8. * IPROP
  9. *
  10. */
  11. // #include <_glheap.h>
  12. typedef struct _UNKOBJ FAR * LPUNKOBJ;
  13. /* The instance portion of UNKOBJ structure members.
  14. */
  15. typedef struct _UNKINST
  16. {
  17. LPALLOCATEBUFFER lpfAllocateBuffer;
  18. LPALLOCATEMORE lpfAllocateMore;
  19. LPFREEBUFFER lpfFreeBuffer;
  20. LPMALLOC lpmalloc;
  21. HINSTANCE hinst;
  22. } UNKINST, * PUNKINST;
  23. typedef ULONG IDS;
  24. #ifndef BEGIN_INTERFACE
  25. #define BEGIN_INTERFACE
  26. #endif
  27. /*
  28. * Vtable alignment
  29. */
  30. #ifndef VTABLE_FILL
  31. #ifdef MAC
  32. #define VTABLE_FILL NULL,
  33. #else
  34. #define VTABLE_FILL
  35. #endif
  36. #endif
  37. /*============================================================================
  38. *
  39. * UNKOBJ (IUnknown) Class
  40. */
  41. #define cchLastError 1024
  42. #define MAPI_IMAPIUNKNOWN_METHODS(IPURE) \
  43. MAPIMETHOD(GetLastError) \
  44. (THIS_ HRESULT hResult, \
  45. ULONG ulFlags, \
  46. LPMAPIERROR FAR * lppMAPIError) IPURE; \
  47. #undef INTERFACE
  48. #define INTERFACE struct _UNKOBJ
  49. #undef METHOD_PREFIX
  50. #define METHOD_PREFIX UNKOBJ_
  51. #undef LPVTBL_ELEM
  52. #define LPVTBL_ELEM lpvtbl
  53. #undef MAPIMETHOD_
  54. #define MAPIMETHOD_(type,method) MAPIMETHOD_DECLARE(type,method,UNKOBJ_)
  55. MAPI_IUNKNOWN_METHODS(IMPL)
  56. MAPI_IMAPIUNKNOWN_METHODS(IMPL)
  57. #undef MAPIMETHOD_
  58. #define MAPIMETHOD_(type,method) STDMETHOD_(type,method)
  59. DECLARE_MAPI_INTERFACE(UNKOBJ_)
  60. {
  61. BEGIN_INTERFACE
  62. MAPI_IUNKNOWN_METHODS(IMPL)
  63. MAPI_IMAPIUNKNOWN_METHODS(IMPL)
  64. };
  65. #define UNKOBJ_MEMBERS \
  66. ULONG ulcbVtbl; \
  67. ULONG ulcRef; \
  68. LPIID FAR * rgpiidList; \
  69. ULONG ulcIID; \
  70. CRITICAL_SECTION csid; \
  71. UNKINST * pinst; \
  72. HRESULT hrLastError; \
  73. IDS idsLastError; \
  74. HLH lhHeap
  75. typedef struct _UNKOBJ
  76. {
  77. UNKOBJ_Vtbl FAR * lpvtbl;
  78. UNKOBJ_MEMBERS;
  79. } UNKOBJ;
  80. #ifndef WIN16
  81. __inline VOID
  82. UNKOBJ_EnterCriticalSection( LPUNKOBJ lpunkobj )
  83. {
  84. EnterCriticalSection(&lpunkobj->csid);
  85. }
  86. __inline VOID
  87. UNKOBJ_LeaveCriticalSection( LPUNKOBJ lpunkobj )
  88. {
  89. LeaveCriticalSection(&lpunkobj->csid);
  90. }
  91. __inline HRESULT
  92. UNKOBJ_HrSetLastResult( LPUNKOBJ lpunkobj,
  93. HRESULT hResult,
  94. IDS idsError )
  95. {
  96. UNKOBJ_EnterCriticalSection(lpunkobj);
  97. lpunkobj->idsLastError = idsError;
  98. lpunkobj->hrLastError = hResult;
  99. UNKOBJ_LeaveCriticalSection(lpunkobj);
  100. return hResult;
  101. }
  102. __inline HRESULT
  103. UNKOBJ_HrSetLastError( LPUNKOBJ lpunkobj,
  104. SCODE sc,
  105. IDS idsError )
  106. {
  107. UNKOBJ_EnterCriticalSection(lpunkobj);
  108. lpunkobj->idsLastError = idsError;
  109. lpunkobj->hrLastError = ResultFromScode(sc);
  110. UNKOBJ_LeaveCriticalSection(lpunkobj);
  111. return ResultFromScode(sc);
  112. }
  113. __inline VOID
  114. UNKOBJ_SetLastError( LPUNKOBJ lpunkobj,
  115. SCODE sc,
  116. IDS idsError )
  117. {
  118. lpunkobj->idsLastError = idsError;
  119. lpunkobj->hrLastError = ResultFromScode(sc);
  120. }
  121. __inline VOID
  122. UNKOBJ_SetLastErrorSc( LPUNKOBJ lpunkobj,
  123. SCODE sc )
  124. {
  125. lpunkobj->hrLastError = ResultFromScode(sc);
  126. }
  127. __inline VOID
  128. UNKOBJ_SetLastErrorIds( LPUNKOBJ lpunkobj,
  129. IDS ids )
  130. {
  131. lpunkobj->idsLastError = ids;
  132. }
  133. #else // !WIN16
  134. // !!! Watcom C compiler does not support inline.
  135. // The functions are defined in UNKOBJ.C
  136. VOID UNKOBJ_EnterCriticalSection( LPUNKOBJ lpunkobj );
  137. VOID UNKOBJ_LeaveCriticalSection( LPUNKOBJ lpunkobj );
  138. HRESULT UNKOBJ_HrSetLastResult( LPUNKOBJ lpunkobj, HRESULT hResult, IDS idsError );
  139. HRESULT UNKOBJ_HrSetLastError( LPUNKOBJ lpunkobj, SCODE sc, IDS idsError );
  140. VOID UNKOBJ_SetLastError( LPUNKOBJ lpunkobj, SCODE sc, IDS idsError );
  141. VOID UNKOBJ_SetLastErrorSc( LPUNKOBJ lpunkobj, SCODE sc );
  142. VOID UNKOBJ_SetLastErrorIds( LPUNKOBJ lpunkobj, IDS ids );
  143. #endif // !WIN16
  144. STDAPI_(SCODE)
  145. UNKOBJ_Init( LPUNKOBJ lpunkobj,
  146. UNKOBJ_Vtbl FAR * lpvtblUnkobj,
  147. ULONG ulcbVtbl,
  148. LPIID FAR * rgpiidList,
  149. ULONG ulcIID,
  150. PUNKINST punkinst );
  151. STDAPI_(VOID)
  152. UNKOBJ_Deinit( LPUNKOBJ lpunkobj );
  153. STDAPI_(SCODE)
  154. UNKOBJ_ScAllocate( LPUNKOBJ lpunkobj,
  155. ULONG ulcb,
  156. LPVOID FAR * lppv );
  157. STDAPI_(SCODE)
  158. UNKOBJ_ScAllocateMore( LPUNKOBJ lpunkobj,
  159. ULONG ulcb,
  160. LPVOID lpv,
  161. LPVOID FAR * lppv );
  162. STDAPI_(VOID)
  163. UNKOBJ_Free( LPUNKOBJ lpunkobj,
  164. LPVOID lpv );
  165. STDAPI_(VOID)
  166. UNKOBJ_FreeRows( LPUNKOBJ lpunkobj,
  167. LPSRowSet lprows );
  168. STDAPI_(SCODE)
  169. UNKOBJ_ScCOAllocate( LPUNKOBJ lpunkobj,
  170. ULONG ulcb,
  171. LPVOID FAR * lppv );
  172. STDAPI_(SCODE)
  173. UNKOBJ_ScCOReallocate( LPUNKOBJ lpunkobj,
  174. ULONG ulcb,
  175. LPVOID FAR * lplpv );
  176. STDAPI_(VOID)
  177. UNKOBJ_COFree( LPUNKOBJ lpunkobj,
  178. LPVOID lpv );
  179. STDAPI_(SCODE)
  180. UNKOBJ_ScSzFromIdsAlloc( LPUNKOBJ lpunkobj,
  181. IDS ids,
  182. ULONG ulFlags,
  183. int cchBuf,
  184. LPTSTR FAR * lpszBuf );
  185. STDAPI_(SCODE)
  186. UNKOBJ_ScSzFromIdsAllocMore( LPUNKOBJ lpunkobj,
  187. IDS ids,
  188. ULONG ulFlags,
  189. LPVOID lpvBase,
  190. int cchBuf,
  191. LPTSTR FAR * lppszBuf );
  192. /* These should be moved to a more useful (generic) location (mapidefs.h?).
  193. */
  194. #ifdef WIN16
  195. /* IsEqualGUID is used to eliminate dependency on compob(j/32).lib. This
  196. * is only necessary on WIN16 because all other platforms define this
  197. * already. (see objbase.h)
  198. */
  199. #define IsEqualGUID(a, b) (memcmp((a), (b), sizeof(GUID)) == 0)
  200. #endif