home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / MSINC.PAK / SCODE.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  11KB  |  314 lines

  1. /*
  2.  *      C/C++ Run Time Library - Version 6.5
  3.  *
  4.  *      Copyright (c) 1994 by Borland International
  5.  *      All Rights Reserved.
  6.  *
  7.  */
  8.  
  9. /*****************************************************************************\
  10. *                                                                             *
  11. * scode.h -     Defines standard status code services.                                            *
  12. *                                                                             *
  13. *               OLE Version 2.0                                               *
  14. *                                                                             *
  15. \*****************************************************************************/
  16.  
  17.  
  18. #if !defined(__FLAT__)
  19. #ifndef __SCODE_H__
  20. #define __SCODE_H__
  21. #define __SCODE_H
  22.  
  23. //
  24. // SCODE
  25. //
  26.  
  27. typedef long SCODE;
  28. typedef SCODE *PSCODE;
  29. typedef void FAR * HRESULT;
  30. #define NOERROR 0
  31.  
  32. //
  33. //  Status values are 32 bit values layed out as follows:
  34. //
  35. //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  36. //   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
  37. //  +-+---------------------+-------+-------------------------------+
  38. //  |S|       Context       | Facil |               Code            |
  39. //  +-+---------------------+-------+-------------------------------+
  40. //
  41. //  where
  42. //
  43. //      S - is the severity code
  44. //
  45. //          0 - Success
  46. //          1 - Error
  47. //
  48. //      Context - context info
  49. //
  50. //      Facility - is the facility code
  51. //
  52. //      Code - is the facility's status code
  53. //
  54.  
  55. //
  56. // Severity values
  57. //
  58.  
  59. #define SEVERITY_SUCCESS    0
  60. #define SEVERITY_ERROR      1
  61.  
  62.  
  63.  
  64. #define SUCCEEDED(Status) ((SCODE)(Status) >= 0)
  65.  
  66. #define FAILED(Status) ((SCODE)(Status)<0)
  67.  
  68.  
  69. //
  70. // Return the code
  71. //
  72.  
  73. #define SCODE_CODE(sc)      ((sc) & 0xFFFF)
  74.  
  75. //
  76. //  Return the facility
  77. //
  78.  
  79. #define SCODE_FACILITY(sc)  (((sc) >> 16) & 0x1fff)
  80.  
  81. //
  82. //  Return the severity
  83. //
  84.  
  85. #define SCODE_SEVERITY(sc)  (((sc) >> 31) & 0x1)
  86.  
  87. //
  88. // Create an SCODE value from component pieces
  89. //
  90.  
  91. #define MAKE_SCODE(sev,fac,code) \
  92.     ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  93.  
  94.  
  95.  
  96. // --------------------- Functions ---------------------------------------
  97.  
  98. #define GetScode(hr)        ((SCODE)(hr) & 0x800FFFFFL)
  99. #define ResultFromScode(sc) ((HRESULT)((SCODE)(sc) & 0x800FFFFFL))
  100.  
  101. STDAPI PropagateResult(HRESULT hrPrev, SCODE scNew);
  102.  
  103.  
  104. // -------------------------- Facility definitions -------------------------
  105.  
  106. #define FACILITY_NULL       0x0000 // generally useful errors ([SE]_*)
  107. #define FACILITY_RPC            0x0001 // remote procedure call errors (RPC_E_*)
  108. #define FACILITY_DISPATCH   0x0002 // late binding dispatch errors
  109. #define FACILITY_STORAGE   0x0003 // storage errors (STG_E_*)
  110. #define FACILITY_ITF            0x0004 // interface-specific errors
  111.  
  112.  
  113.  
  114. #define S_OK                0L
  115. #define S_FALSE             MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  116.  
  117.  
  118.  
  119. // --------------------- FACILITY_NULL errors ------------------------------
  120.  
  121. #define E_UNEXPECTED        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 0xffff)
  122.                 // relatively catastrophic failure
  123.  
  124. #define E_NOTIMPL           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 1)
  125.                 // not implemented
  126.  
  127. #define E_OUTOFMEMORY       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 2)
  128.                 // ran out of memory
  129.  
  130. #define E_INVALIDARG        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 3)
  131.                 // one or more arguments are invalid
  132.  
  133. #define E_NOINTERFACE       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 4)
  134.                 // no such interface supported
  135.  
  136.  
  137. #define E_POINTER           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 5)
  138.                 // invalid pointer
  139.  
  140. #define E_HANDLE            MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 6)
  141.                 // invalid handle
  142.  
  143. #define E_ABORT             MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 7)
  144.                 // operation aborted
  145.  
  146. #define E_FAIL              MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 8)
  147.                 // unspecified error
  148.  
  149.  
  150. #define E_ACCESSDENIED      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 9)
  151.                 // general access denied error
  152.  
  153.  
  154. // ----------------- FACILITY_ITF errors used by OLE ---------------------
  155. //
  156. // By convention, OLE interfaces divide the FACILITY_ITF range of errors
  157. // into nonoverlapping subranges.  If an OLE interface returns a FACILITY_ITF
  158. // scode, it must be from the range associated with that interface or from
  159. // the shared range: OLE_E_FIRST...OLE_E_LAST.
  160. //
  161. // The ranges, their associated interfaces, and the header file that defines
  162. // the actual scodes are given below.
  163. //
  164.  
  165. // Generic OLE errors that may be returned by many interfaces
  166. #define OLE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0000)
  167. #define OLE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x00FF)
  168. #define OLE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0000)
  169. #define OLE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x00FF)
  170. // interfaces: all
  171. // file: ole2.h
  172.  
  173.  
  174. #define DRAGDROP_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0100)
  175. #define DRAGDROP_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x010F)
  176. #define DRAGDROP_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0100)
  177. #define DRAGDROP_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x010F)
  178. // interfaces: IDropSource, IDropTarget
  179. // file: ole2.h
  180.  
  181. #define CLASSFACTORY_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0110)
  182. #define CLASSFACTORY_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x011F)
  183. #define CLASSFACTORY_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0110)
  184. #define CLASSFACTORY_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x011F)
  185. // interfaces: IClassFactory
  186. // file:
  187.  
  188. #define MARSHAL_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0120)
  189. #define MARSHAL_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x012F)
  190. #define MARSHAL_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0120)
  191. #define MARSHAL_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x012F)
  192. // interfaces: IMarshal, IStdMarshalInfo, marshal APIs
  193. // file:
  194.  
  195. #define DATA_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0130)
  196. #define DATA_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x013F)
  197. #define DATA_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0130)
  198. #define DATA_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x013F)
  199. // interfaces: IDataObject
  200. // file: dvobj.h
  201.  
  202. #define VIEW_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0140)
  203. #define VIEW_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x014F)
  204. #define VIEW_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0140)
  205. #define VIEW_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x014F)
  206. // interfaces: IViewObject
  207. // file: dvobj.h
  208.  
  209. #define REGDB_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0150)
  210. #define REGDB_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x015F)
  211. #define REGDB_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0150)
  212. #define REGDB_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x015F)
  213. // API: reg.dat manipulation
  214. // file:
  215.  
  216.  
  217. // range 160 - 16F reserved
  218.  
  219. #define CACHE_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0170)
  220. #define CACHE_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x017F)
  221. #define CACHE_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0170)
  222. #define CACHE_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x017F)
  223. // interfaces: IOleCache
  224. // file:
  225.  
  226. #define OLEOBJ_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0180)
  227. #define OLEOBJ_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x018F)
  228. #define OLEOBJ_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0180)
  229. #define OLEOBJ_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x018F)
  230. // interfaces: IOleObject
  231. // file:
  232.  
  233. #define CLIENTSITE_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0190)
  234. #define CLIENTSITE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x019F)
  235. #define CLIENTSITE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0190)
  236. #define CLIENTSITE_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x019F)
  237. // interfaces: IOleClientSite
  238. // file:
  239.  
  240. #define INPLACE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01A0)
  241. #define INPLACE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01AF)
  242. #define INPLACE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01A0)
  243. #define INPLACE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01AF)
  244. // interfaces: IOleWindow, IOleInPlaceObject, IOleInPlaceActiveObject,
  245. //                 IOleInPlaceUIWindow, IOleInPlaceFrame, IOleInPlaceSite
  246. // file:
  247.  
  248. #define ENUM_E_FIRST        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01B0)
  249. #define ENUM_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01BF)
  250. #define ENUM_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01B0)
  251. #define ENUM_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01BF)
  252. // interfaces: IEnum*
  253. // file:
  254.  
  255. #define CONVERT10_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01C0)
  256. #define CONVERT10_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01CF)
  257. #define CONVERT10_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01C0)
  258. #define CONVERT10_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01CF)
  259. // API: OleConvertOLESTREAMToIStorage, OleConvertIStorageToOLESTREAM
  260. // file:
  261.  
  262.  
  263. #define CLIPBRD_E_FIRST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01D0)
  264. #define CLIPBRD_E_LAST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01DF)
  265. #define CLIPBRD_S_FIRST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01D0)
  266. #define CLIPBRD_S_LAST      MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01DF)
  267. // interfaces: OleSetClipboard, OleGetClipboard, OleFlushClipboard
  268. // file: ole2.h
  269.  
  270. #define MK_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01E0)
  271. #define MK_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01EF)
  272. #define MK_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01E0)
  273. #define MK_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01EF)
  274. // interfaces: IMoniker, IBindCtx, IRunningObjectTable, IParseDisplayName,
  275. //             IOleContainer, IOleItemContainer, IOleLink
  276. // file: moniker.h
  277.  
  278.  
  279. #define CO_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01F0)
  280. #define CO_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01FF)
  281. #define CO_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01F0)
  282. #define CO_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01FF)
  283. // all Co* API
  284. // file: compobj.h
  285.  
  286.  
  287. // range 200 - ffff for new error codes
  288.  
  289.  
  290. #endif      // ifndef __SCODE_H__
  291.  
  292. #else  /* !__FLAT__ */
  293. /*++
  294.  
  295. Copyright (c) 1992 - 1995 Microsoft Corporation
  296.  
  297. Module Name:
  298.  
  299.     scode.h
  300.  
  301. Abstract:
  302.  
  303.     Obsolete SCODE header file.  Use WINERROR.H
  304.  
  305. --*/
  306.  
  307. #ifndef  _WINERROR_
  308. #include <winerror.h>
  309. #endif
  310.  
  311. #endif  /* __FLAT__ */
  312.  
  313.  
  314.