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.

72 lines
2.8 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. RsOpt.h
  5. Abstract:
  6. Special error handling macros for RsOptCom and RsCln.
  7. Author:
  8. Carl Hagerstrom [carlh] 20-Aug-1998
  9. Revision History:
  10. --*/
  11. #ifndef _RSOPT_H
  12. #define _RSOPT_H
  13. #define RsOptThrow(hr) throw ((HRESULT)hr)
  14. #define RsOptLastError (HRESULT_FROM_WIN32(GetLastError()))
  15. #define RsOptAffirm(cond,hr) if (!(cond)) RsOptThrow(hr)
  16. #define RsOptAffirmStatus(stat) RsOptAffirm(stat, RsOptLastError)
  17. #define RsOptAffirmPointer(ptr) RsOptAffirm(ptr, E_POINTER)
  18. #define RsOptAffirmAlloc(ptr) RsOptAffirm(ptr, E_OUTOFMEMORY)
  19. #define RsOptAffirmHr(hr) \
  20. { \
  21. HRESULT lHr; \
  22. lHr = (hr); \
  23. RsOptAffirm(SUCCEEDED(lHr), lHr); \
  24. }
  25. #define RsOptAffirmHandle(hndl) \
  26. { \
  27. HANDLE _hndl; \
  28. _hndl = (hndl); \
  29. RsOptAffirm(_hndl && _hndl != INVALID_HANDLE_VALUE, RsOptLastError); \
  30. }
  31. #define RsOptAffirmNtStatus(ntstat) \
  32. { \
  33. NTSTATUS _ntstat; \
  34. _ntstat = (ntstat); \
  35. RsOptAffirm(NT_SUCCESS(_ntstat), HRESULT_FROM_NT(_ntstat)); \
  36. }
  37. #define RsOptAffirmDw(hr) \
  38. { \
  39. HRESULT _hr; \
  40. _hr = (hr); \
  41. RsOptAffirm(SUCCEEDED(_hr), _hr); \
  42. }
  43. #define RsOptAffirmWin32(stat) \
  44. { \
  45. LONG _stat; \
  46. _stat = (stat); \
  47. RsOptAffirm(_stat == ERROR_SUCCESS, HRESULT_FROM_WIN32(_stat)); \
  48. }
  49. #define RsOptCatch(retval) \
  50. catch(HRESULT _retval) \
  51. { \
  52. retval = _retval; \
  53. }
  54. #endif // _RSOPT_H