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.

110 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. rndcommc.h
  5. Abstract:
  6. This module provides common definitions used in rendezvous control.
  7. --*/
  8. #ifndef __REND_COMMON_C__
  9. #define __REND_COMMON_C__
  10. #include "rend.h"
  11. #include "rendp.h"
  12. #define WINSOCKVERSION 0x0200
  13. typedef ITDirectory * PDIRECTORY;
  14. typedef ITDirectoryObject * PDIRECTORYOBJECT;
  15. #define MeetingAttrIndex(a) ((a) - MEETING_ATTRIBUTES_BEGIN - 1)
  16. #define UserAttrIndex(a) ((a) - USER_ATTRIBUTES_BEGIN - 1)
  17. #define ValidMeetingAttribute(a) \
  18. (((a) > MEETING_ATTRIBUTES_BEGIN) && ((a) < MEETING_ATTRIBUTES_END))
  19. #define ValidUserAttribute(a) \
  20. (((a) > USER_ATTRIBUTES_BEGIN) && ((a) < USER_ATTRIBUTES_END))
  21. extern const WCHAR * const MeetingAttributeNames[];
  22. extern const WCHAR * const UserAttributeNames[];
  23. #define UserAttributeName(a) (UserAttributeNames[UserAttrIndex(a)])
  24. #define MeetingAttributeName(a) (MeetingAttributeNames[MeetingAttrIndex(a)])
  25. // sets the first bit to indicate error
  26. // sets the win32 facility code
  27. // this is used instead of the HRESULT_FROM_WIN32 macro
  28. // because that clears the customer flag
  29. inline long
  30. HRESULT_FROM_ERROR_CODE(IN long ErrorCode)
  31. {
  32. LOG((MSP_ERROR, "HRESULT_FROM_ERROR_CODE - error %x",
  33. (0x80070000 | (0xa000ffff & ErrorCode))));
  34. return ( 0x80070000 | (0xa000ffff & ErrorCode) );
  35. }
  36. inline BOOL
  37. CUSTOMER_FLAG_ON(IN long ErrorValue)
  38. {
  39. return (0x20000000 & ErrorValue);
  40. }
  41. template <class T>
  42. inline BOOL BadReadPtr(T* p, DWORD dwSize = 1)
  43. {
  44. return IsBadReadPtr(p, dwSize * sizeof(T));
  45. }
  46. template <class T>
  47. inline BOOL BadWritePtr(T* p, DWORD dwSize = 1)
  48. {
  49. return IsBadWritePtr(p, dwSize * sizeof(T));
  50. }
  51. #define BAIL_IF_FAIL(HResultExpr, msg) \
  52. { \
  53. HRESULT MacroHResult = HResultExpr; \
  54. if (FAILED(MacroHResult)) \
  55. { \
  56. LOG((MSP_ERROR, "%s - error %x", msg, MacroHResult)); \
  57. return MacroHResult; \
  58. } \
  59. }
  60. #define BAIL_IF_NULL(Ptr, ReturnValue) \
  61. { \
  62. if ( NULL == Ptr ) \
  63. { \
  64. LOG((MSP_ERROR, "NULL_PTR - ret value %x", ReturnValue)); \
  65. return ReturnValue; \
  66. } \
  67. }
  68. #define BAIL_IF_BAD_READ_PTR(Ptr, ReturnValue) \
  69. { \
  70. if ( BadReadPtr(Ptr) ) \
  71. { \
  72. LOG((MSP_ERROR, "BAD_READ_PTR - ret value %x", ReturnValue));\
  73. return ReturnValue; \
  74. } \
  75. }
  76. #define BAIL_IF_BAD_WRITE_PTR(Ptr, ReturnValue) \
  77. { \
  78. if ( BadWritePtr(Ptr) ) \
  79. { \
  80. LOG((MSP_ERROR, "BAD_WRITE_PTR - ret value %x", ReturnValue)); \
  81. return ReturnValue; \
  82. } \
  83. }
  84. #endif // __REND_COMMON_C__