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.

281 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: SCode.h
  4. //
  5. // Contents: Defines standard status code services.
  6. //
  7. //
  8. //----------------------------------------------------------------------------
  9. #ifndef __SCODE_H__
  10. #define __SCODE_H__
  11. //
  12. // SCODE
  13. //
  14. typedef long SCODE;
  15. typedef SCODE *PSCODE;
  16. typedef void FAR * HRESULT;
  17. #define NOERROR 0
  18. //
  19. // Status values are 32 bit values layed out as follows:
  20. //
  21. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  22. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  23. // +-+---------------------+-------+-------------------------------+
  24. // |S| Context | Facil | Code |
  25. // +-+---------------------+-------+-------------------------------+
  26. //
  27. // where
  28. //
  29. // S - is the severity code
  30. //
  31. // 0 - Success
  32. // 1 - Error
  33. //
  34. // Context - context info
  35. //
  36. // Facility - is the facility code
  37. //
  38. // Code - is the facility's status code
  39. //
  40. //
  41. // Severity values
  42. //
  43. #define SEVERITY_SUCCESS 0
  44. #define SEVERITY_ERROR 1
  45. #define SUCCEEDED(Status) ((SCODE)(Status) >= 0)
  46. #define FAILED(Status) ((SCODE)(Status)<0)
  47. //
  48. // Return the code
  49. //
  50. #define SCODE_CODE(sc) ((sc) & 0xFFFF)
  51. //
  52. // Return the facility
  53. //
  54. #define SCODE_FACILITY(sc) (((sc) >> 16) & 0x1fff)
  55. //
  56. // Return the severity
  57. //
  58. #define SCODE_SEVERITY(sc) (((sc) >> 31) & 0x1)
  59. //
  60. // Create an SCODE value from component pieces
  61. //
  62. #define MAKE_SCODE(sev,fac,code) \
  63. ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  64. // --------------------- Functions ---------------------------------------
  65. #define GetScode(hr) ((SCODE)(hr) & 0x800FFFFF)
  66. #define ResultFromScode(sc) ((HRESULT)((SCODE)(sc) & 0x800FFFFF))
  67. STDAPI PropagateResult(HRESULT hrPrev, SCODE scNew);
  68. // -------------------------- Facility definitions -------------------------
  69. #define FACILITY_NULL 0x0000 // generally useful errors ([SE]_*)
  70. #define FACILITY_RPC 0x0001 // remote procedure call errors (RPC_E_*)
  71. #define FACILITY_DISPATCH 0x0002 // late binding dispatch errors
  72. #define FACILITY_STORAGE 0x0003 // storage errors (STG_E_*)
  73. #define FACILITY_ITF 0x0004 // interface-specific errors
  74. #define S_OK 0L
  75. #define S_FALSE MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  76. // --------------------- FACILITY_NULL errors ------------------------------
  77. #define E_UNEXPECTED MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 0xffff)
  78. // relatively catastrophic failure
  79. #define E_NOTIMPL MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 1)
  80. // not implemented
  81. #define E_OUTOFMEMORY MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 2)
  82. // ran out of memory
  83. #define E_INVALIDARG MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 3)
  84. // one or more arguments are invalid
  85. #define E_NOINTERFACE MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 4)
  86. // no such interface supported
  87. #define E_POINTER MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 5)
  88. // invalid pointer
  89. #define E_HANDLE MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 6)
  90. // invalid handle
  91. #define E_ABORT MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 7)
  92. // operation aborted
  93. #define E_FAIL MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 8)
  94. // unspecified error
  95. #define E_ACCESSDENIED MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 9)
  96. // general access denied error
  97. // ----------------- FACILITY_ITF errors used by OLE ---------------------
  98. //
  99. // By convention, OLE interfaces divide the FACILITY_ITF range of errors
  100. // into nonoverlapping subranges. If an OLE interface returns a FACILITY_ITF
  101. // scode, it must be from the range associated with that interface or from
  102. // the shared range: OLE_E_FIRST...OLE_E_LAST.
  103. //
  104. // The ranges, their associated interfaces, and the header file that defines
  105. // the actual scodes are given below.
  106. //
  107. // Generic OLE errors that may be returned by many interfaces
  108. #define OLE_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0000)
  109. #define OLE_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x00FF)
  110. #define OLE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0000)
  111. #define OLE_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x00FF)
  112. // interfaces: all
  113. // file: ole2.h
  114. #define DRAGDROP_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0100)
  115. #define DRAGDROP_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x010F)
  116. #define DRAGDROP_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0100)
  117. #define DRAGDROP_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x010F)
  118. // interfaces: IDropSource, IDropTarget
  119. // file: ole2.h
  120. #define CLASSFACTORY_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0110)
  121. #define CLASSFACTORY_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x011F)
  122. #define CLASSFACTORY_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0110)
  123. #define CLASSFACTORY_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x011F)
  124. // interfaces: IClassFactory
  125. // file:
  126. #define MARSHAL_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0120)
  127. #define MARSHAL_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x012F)
  128. #define MARSHAL_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0120)
  129. #define MARSHAL_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x012F)
  130. // interfaces: IMarshal, IStdMarshalInfo, marshal APIs
  131. // file:
  132. #define DATA_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0130)
  133. #define DATA_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x013F)
  134. #define DATA_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0130)
  135. #define DATA_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x013F)
  136. // interfaces: IDataObject
  137. // file: dvobj.h
  138. #define VIEW_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0140)
  139. #define VIEW_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x014F)
  140. #define VIEW_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0140)
  141. #define VIEW_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x014F)
  142. // interfaces: IViewObject
  143. // file: dvobj.h
  144. #define REGDB_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0150)
  145. #define REGDB_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x015F)
  146. #define REGDB_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0150)
  147. #define REGDB_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x015F)
  148. // API: reg.dat manipulation
  149. // file:
  150. // range 160 - 16F reserved
  151. #define CACHE_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0170)
  152. #define CACHE_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x017F)
  153. #define CACHE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0170)
  154. #define CACHE_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x017F)
  155. // interfaces: IOleCache
  156. // file:
  157. #define OLEOBJ_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0180)
  158. #define OLEOBJ_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x018F)
  159. #define OLEOBJ_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0180)
  160. #define OLEOBJ_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x018F)
  161. // interfaces: IOleObject
  162. // file:
  163. #define CLIENTSITE_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x0190)
  164. #define CLIENTSITE_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x019F)
  165. #define CLIENTSITE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0190)
  166. #define CLIENTSITE_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x019F)
  167. // interfaces: IOleClientSite
  168. // file:
  169. #define INPLACE_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01A0)
  170. #define INPLACE_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01AF)
  171. #define INPLACE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01A0)
  172. #define INPLACE_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01AF)
  173. // interfaces: IOleWindow, IOleInPlaceObject, IOleInPlaceActiveObject,
  174. // IOleInPlaceUIWindow, IOleInPlaceFrame, IOleInPlaceSite
  175. // file:
  176. #define ENUM_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01B0)
  177. #define ENUM_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01BF)
  178. #define ENUM_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01B0)
  179. #define ENUM_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01BF)
  180. // interfaces: IEnum*
  181. // file:
  182. #define CONVERT10_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01C0)
  183. #define CONVERT10_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01CF)
  184. #define CONVERT10_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01C0)
  185. #define CONVERT10_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01CF)
  186. // API: OleConvertOLESTREAMToIStorage, OleConvertIStorageToOLESTREAM
  187. // file:
  188. #define CLIPBRD_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01D0)
  189. #define CLIPBRD_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01DF)
  190. #define CLIPBRD_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01D0)
  191. #define CLIPBRD_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01DF)
  192. // interfaces: OleSetClipboard, OleGetClipboard, OleFlushClipboard
  193. // file: ole2.h
  194. #define MK_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01E0)
  195. #define MK_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01EF)
  196. #define MK_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01E0)
  197. #define MK_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01EF)
  198. // interfaces: IMoniker, IBindCtx, IRunningObjectTable, IParseDisplayName,
  199. // IOleContainer, IOleItemContainer, IOleLink
  200. // file: moniker.h
  201. #define CO_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01F0)
  202. #define CO_E_LAST MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x01FF)
  203. #define CO_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01F0)
  204. #define CO_S_LAST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01FF)
  205. // all Co* API
  206. // file: compobj.h
  207. // range 200 - ffff for new error codes
  208. #endif // ifndef __SCODE_H__